Commit 53b11ef2 authored by Sergey Petrunya's avatar Sergey Petrunya

Post-merge fixes: Fix problems in table_elim.test and enable it.

parent 08115a80
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
# #
############################################################################## ##############################################################################
events_time_zone : Test is not predictable as it depends on precise timing. events_time_zone : Test is not predictable as it depends on precise timing.
table_elim : sergeyp to reapply 2643.26.4 in Item_sum::update_used_tables
lowercase_table3 : Bug#11762269 2010-06-30 alik main.lowercase_table3 on Mac OSX lowercase_table3 : Bug#11762269 2010-06-30 alik main.lowercase_table3 on Mac OSX
read_many_rows_innodb : Bug#11748886 2010-11-15 mattiasj report already exists read_many_rows_innodb : Bug#11748886 2010-11-15 mattiasj report already exists
sum_distinct-big : Bug#11764126 2010-11-15 mattiasj was not tested sum_distinct-big : Bug#11764126 2010-11-15 mattiasj was not tested
......
...@@ -1424,7 +1424,11 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref) ...@@ -1424,7 +1424,11 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
cache->setup(args[0]); cache->setup(args[0]);
if (cache->cols() == 1) if (cache->cols() == 1)
{ {
if ((used_tables_cache= args[0]->used_tables())) /*
Note: there can be cases when used_tables()==0 && !const_item(). See
Item_sum::update_used_tables for details.
*/
if ((used_tables_cache= args[0]->used_tables()) || !args[0]->const_item())
cache->set_used_tables(OUTER_REF_TABLE_BIT); cache->set_used_tables(OUTER_REF_TABLE_BIT);
else else
cache->set_used_tables(0); cache->set_used_tables(0);
...@@ -1434,7 +1438,8 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref) ...@@ -1434,7 +1438,8 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
uint n= cache->cols(); uint n= cache->cols();
for (uint i= 0; i < n; i++) for (uint i= 0; i < n; i++)
{ {
if (args[0]->element_index(i)->used_tables()) Item *element=args[0]->element_index(i);
if (element->used_tables() || !element->const_item())
((Item_cache *)cache->element_index(i))->set_used_tables(OUTER_REF_TABLE_BIT); ((Item_cache *)cache->element_index(i))->set_used_tables(OUTER_REF_TABLE_BIT);
else else
((Item_cache *)cache->element_index(i))->set_used_tables(0); ((Item_cache *)cache->element_index(i))->set_used_tables(0);
......
...@@ -550,11 +550,20 @@ void Item_sum::update_used_tables () ...@@ -550,11 +550,20 @@ void Item_sum::update_used_tables ()
args[i]->update_used_tables(); args[i]->update_used_tables();
used_tables_cache|= args[i]->used_tables(); used_tables_cache|= args[i]->used_tables();
} }
/*
MariaDB: don't run the following {
used_tables_cache&= PSEUDO_TABLE_BITS; used_tables_cache&= PSEUDO_TABLE_BITS;
/* the aggregate function is aggregated into its local context */ // the aggregate function is aggregated into its local context
used_tables_cache |= (1 << aggr_sel->join->table_count) - 1; used_tables_cache |= (1 << aggr_sel->join->table_count) - 1;
} because if we do it, table elimination will assume that
- constructs like "COUNT(*)" use columns from all tables
- so, it is not possible to eliminate any table
our solution for COUNT(*) is that it has
item->used_tables() == 0 && !item->const_item()
*/
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment