diff options
author | unknown <evgen@moonbone.local> | 2006-01-11 22:49:43 +0300 |
---|---|---|
committer | unknown <evgen@moonbone.local> | 2006-01-11 22:49:43 +0300 |
commit | 593bed0d929cdc2827439d4697ce6f4b2bc9d941 (patch) | |
tree | 6b8d0de32ad9d2874c9c9803e328edad542e33fa /sql/item_cmpfunc.cc | |
parent | 95cabee1dc3a6d44a7e7a4c74c0bd49e00047f5b (diff) | |
download | mariadb-git-593bed0d929cdc2827439d4697ce6f4b2bc9d941.tar.gz |
Fixed bug #15633: Evaluation of Item_equal for non-const table caused wrong
select result
Item equal objects are employed only at the optimize phase. Usually they are not
supposed to be evaluated. Yet in some cases we call the method val_int() for
them. Here we have to take care of restricting the predicate such an object
represents f1=f2= ...=fn to the projection of known fields fi1=...=fik.
Added a check for field's table being const in Item_equal::val_int().
If the field's table is not const val_int() just skips that field when
evaluating Item_equal.
mysql-test/t/select.test:
Added test case for bug #15633: Evaluation of Item_equal for non-const table caused wrong select result
mysql-test/r/select.result:
Added test case for bug #15633: Evaluation of Item_equal for non-const table caused wrong select result
mysql-test/r/func_group.result:
Corrected test result for bug #12882 after fix for bug#15633
sql/item_cmpfunc.h:
Fixed bug #15633: Evaluation of Item_equal for non-const table caused wrong select result
Added comment about fields from non-const tables in class description.
sql/item_cmpfunc.cc:
Fixed bug #15633: Evaluation of Item_equal for non-const table caused wrong select result
Added check for field's table being const in Item_equal::val_int().
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 15614a32c39..306277aa438 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -3765,6 +3765,7 @@ void Item_equal::update_used_tables() longlong Item_equal::val_int() { + Item_field *item_field; if (cond_false) return 0; List_iterator_fast<Item_field> it(fields); @@ -3772,10 +3773,14 @@ longlong Item_equal::val_int() if ((null_value= item->null_value)) return 0; eval_item->store_value(item); - while ((item= it++)) + while ((item_field= it++)) { - if ((null_value= item->null_value) || eval_item->cmp(item)) - return 0; + /* Skip fields of non-const tables. They haven't been read yet */ + if (item_field->field->table->const_table) + { + if ((null_value= item_field->null_value) || eval_item->cmp(item_field)) + return 0; + } } return 1; } |