Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1970 05/12/26 17:42:08 evgen@stripped +5 -0
Fix bug #15633 Evaluation of Item_equal for non-const table caused wrong
select result
Item_equal supposed to exist only on optimize stage, thus its val_int() can
evaluate only for const tables fields because only them have been
read at this stage. But this restriction of const table wasn't checked in
val_int(), resulting in wrong result set.
To Item_equal::val_int() added check for field's table being const, and if
it is not const val_int() just skips that field from eveluation. It will
be checked later on execution stage.
sql/item_cmpfunc.cc
1.188 05/12/26 17:40:52 evgen@stripped +8 -3
Fix bug #15633 Evaluation of Item_equal for non-const table caused wrong select result
To Item_equal::val_int() added check for field's table being const.
sql/item_cmpfunc.h
1.117 05/12/26 17:40:39 evgen@stripped +5 -0
Fix bug #15633 Evaluation of Item_equal for non-const table caused wrong select result
Added comment about Item_equal::val_int()
mysql-test/r/func_group.result
1.47 05/12/26 17:39:56 evgen@stripped +2 -0
Corrected test result for bug #12882 after fix for bug#15633
mysql-test/r/select.result
1.115 05/12/26 17:39:42 evgen@stripped +13 -0
Test case for bug#15633 Evaluation of Item_equal for non-const table caused wrong select result
mysql-test/t/select.test
1.94 05/12/26 17:39:18 evgen@stripped +14 -0
Test case for bug#15633 Evaluation of Item_equal for non-const table caused wrong select result
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: evgen
# Host: moonbone.local
# Root: /work/15633-bug-5.0-mysql
--- 1.187/sql/item_cmpfunc.cc 2005-12-03 07:42:27 +03:00
+++ 1.188/sql/item_cmpfunc.cc 2005-12-26 17:40:52 +03:00
@@ -3765,6 +3765,7 @@
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 @@
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;
}
--- 1.116/sql/item_cmpfunc.h 2005-10-21 05:01:31 +04:00
+++ 1.117/sql/item_cmpfunc.h 2005-12-26 17:40:39 +03:00
@@ -1150,6 +1150,11 @@
are deleted in the end of execution. All changes made to these
objects need not be registered in the list of changes of the parse
tree and do not harm PS/SP re-execution.
+
+ Because Item_equal supposed to exist only on optimization stage,
+ Item_equal::val_int() will evaluate only const tables fields.
+ Fields of regular tables isn't readed at this time, and thus
+ skipped from evaluation.
*/
class Item_equal: public Item_bool_func
--- 1.46/mysql-test/r/func_group.result 2005-09-23 11:18:52 +04:00
+++ 1.47/mysql-test/r/func_group.result 2005-12-26 17:39:56 +03:00
@@ -865,6 +865,7 @@
1 NULL
select 1, min(1) from t1m where a=99;
1 min(1)
+1 NULL
select 1, min(1) from t1m where 1=99;
1 min(1)
1 NULL
@@ -876,6 +877,7 @@
1 NULL
select 1, max(1) from t1m where a=99;
1 max(1)
+1 NULL
select 1, max(1) from t1m where 1=99;
1 max(1)
1 NULL
--- 1.114/mysql-test/r/select.result 2005-11-26 05:51:39 +03:00
+++ 1.115/mysql-test/r/select.result 2005-12-26 17:39:42 +03:00
@@ -3337,3 +3337,16 @@
1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using index
1 SIMPLE t3 const PRIMARY PRIMARY 8 const,const 1
DROP TABLE t1,t2,t3;
+create table t1 (f1 int unique);
+create table t2 (f2 int unique);
+create table t3 (f3 int unique);
+insert into t1 values(1),(2);
+insert into t2 values(1),(2);
+insert into t3 values(1),(NULL);
+select * from t3 where f3 is null;
+f3
+NULL
+select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1;
+f2
+1
+drop table t1,t2,t3;
--- 1.93/mysql-test/t/select.test 2005-11-26 05:51:39 +03:00
+++ 1.94/mysql-test/t/select.test 2005-12-26 17:39:18 +03:00
@@ -2805,3 +2805,17 @@
WHERE t2.key_a=2 and key_b=5;
DROP TABLE t1,t2,t3;
+
+#
+# Bug #15633 Evaluation of Item_equal for non-const table caused wrong
+# select result
+#
+create table t1 (f1 int unique);
+create table t2 (f2 int unique);
+create table t3 (f3 int unique);
+insert into t1 values(1),(2);
+insert into t2 values(1),(2);
+insert into t3 values(1),(NULL);
+select * from t3 where f3 is null;
+select t2.f2 from t1 left join t2 on f1=f2 join t3 on f1=f3 where f1=1;
+drop table t1,t2,t3;
| Thread |
|---|
| • bk commit into 5.0 tree (evgen:1.1970) BUG#15633 | eugene | 26 Dec |