summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <igor@rurik.mysql.com>2006-03-31 21:26:17 -0800
committerunknown <igor@rurik.mysql.com>2006-03-31 21:26:17 -0800
commit5ef6e903a462cd2f662d7c7ff9f8993431ec3974 (patch)
treec1688ec4197dcfa4edd2249ba974db0f44a99132 /sql/item_cmpfunc.cc
parent86504f87851d7eb5947d3bba41ae0ddf45aa92ab (diff)
downloadmariadb-git-5ef6e903a462cd2f662d7c7ff9f8993431ec3974.tar.gz
Fixed bug #16504.
Multiple equalities were not adjusted after reading constant tables. It resulted in neglecting good index based methods that could be used to access of other tables. mysql-test/r/having.result: Adjusted a test case results after fix for bug #16504. mysql-test/r/select.result: Added a test case for bug #16504. mysql-test/r/subselect.result: Adjusted a test case results after fix for bug #16504. mysql-test/r/varbinary.result: Adjusted a test case results after fix for bug #16504. mysql-test/t/select.test: Added a test case for bug #16504. sql/item.cc: Fixed bug #16504. An Item_equal object may contain only a constant member. It may happen after reading constant tables. sql/item_cmpfunc.cc: Fixed bug #16504. Added method Item_equal::check_const that check appearance of new constant items in a multiple equality. sql/item_cmpfunc.h: Fixed bug #16504. Added method Item_equal::check_const that check appearance of new constant items in a multiple equality. sql/sql_select.cc: Fixed bug #16504. Adjusted multiple equalities after reading constant tables. Fixed a few typo in comments.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc37
1 files changed, 35 insertions, 2 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 2d74ea9c518..53efb65e1cb 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -3602,7 +3602,8 @@ void Item_equal::add(Item *c)
Item_func_eq *func= new Item_func_eq(c, const_item);
func->set_cmp_func();
func->quick_fix_field();
- cond_false = !(func->val_int());
+ if ((cond_false= !func->val_int()))
+ const_item_cache= 1;
}
void Item_equal::add(Item_field *f)
@@ -3734,13 +3735,45 @@ void Item_equal::sort(Item_field_cmpfunc cmp, void *arg)
} while (swap);
}
+
+/*
+ Check appearance of new constant items in the multiple equality object
+
+ SYNOPSIS
+ check()
+
+ DESCRIPTION
+ The function checks appearance of new constant items among
+ the members of multiple equalities. Each new constant item is
+ compared with the designated constant item if there is any in the
+ multiple equality. If there is none the first new constant item
+ becomes designated.
+
+ RETURN VALUES
+ none
+*/
+
+void Item_equal::check_const()
+{
+ List_iterator<Item_field> it(fields);
+ Item *item;
+ while ((item= it++))
+ {
+ if (item->const_item())
+ {
+ it.remove();
+ add(item);
+ }
+ }
+}
+
bool Item_equal::fix_fields(THD *thd, Item **ref)
{
List_iterator_fast<Item_field> li(fields);
Item *item;
not_null_tables_cache= used_tables_cache= 0;
const_item_cache= 0;
- while ((item=li++))
+ while ((item= li++))
{
table_map tmp_table_map;
used_tables_cache|= item->used_tables();