summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2011-10-27 00:31:44 +0400
committerSergey Petrunya <psergey@askmonty.org>2011-10-27 00:31:44 +0400
commit29d01b0ac787fe4dc14d84e76ef3cf1106bc2179 (patch)
tree5a0531d946a024f42970aadb3cab6d97ec77066c
parent9292953d5ad169a8beda9c1475d28b597f6a80b2 (diff)
parent53b11ef2f47ed976c6fc2e6d16928f8684029ee2 (diff)
downloadmariadb-git-29d01b0ac787fe4dc14d84e76ef3cf1106bc2179.tar.gz
Merge: post-merge fixes
-rw-r--r--mysql-test/t/disabled.def1
-rw-r--r--sql/item_cmpfunc.cc9
-rw-r--r--sql/item_sum.cc19
3 files changed, 21 insertions, 8 deletions
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 2cc734ce24f..45b785e6a80 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -10,7 +10,6 @@
#
##############################################################################
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
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
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 3e7cc24dfd8..c0d3b14b71b 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1424,7 +1424,11 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
cache->setup(args[0]);
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);
else
cache->set_used_tables(0);
@@ -1434,7 +1438,8 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
uint n= cache->cols();
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);
else
((Item_cache *)cache->element_index(i))->set_used_tables(0);
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index d60eb1415b9..0b8ae2d1d54 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -550,11 +550,20 @@ void Item_sum::update_used_tables ()
args[i]->update_used_tables();
used_tables_cache|= args[i]->used_tables();
}
-
- used_tables_cache&= PSEUDO_TABLE_BITS;
-
- /* the aggregate function is aggregated into its local context */
- used_tables_cache |= (1 << aggr_sel->join->table_count) - 1;
+ /*
+ MariaDB: don't run the following {
+
+ used_tables_cache&= PSEUDO_TABLE_BITS;
+
+ // the aggregate function is aggregated into its local context
+ 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()
+ */
}
}