Below is the list of changes that have just been committed into a local
5.0 repository of kgeorge. When kgeorge 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@stripped, 2006-07-13 15:55:18+03:00, gkodinov@stripped +6 -0
Bug #13311: IN + binary lead to incorrect SELECT results
When optimizing equality predicates the collation must be
taken into account. For example a = BINARY 'a' is not the
same as a = 'a' and should not be made into one condition.
mysql-test/r/binary.result@stripped, 2006-07-13 15:55:05+03:00, gkodinov@stripped +12 -0
Bug #13311: IN + binary lead to incorrect SELECT results
* testsuite for the bug
mysql-test/t/binary.test@stripped, 2006-07-13 15:55:06+03:00, gkodinov@stripped +10 -0
Bug #13311: IN + binary lead to incorrect SELECT results
* testsuite for the bug
sql/item.cc@stripped, 2006-07-13 15:55:07+03:00, gkodinov@stripped +1 -1
Bug #13311: IN + binary lead to incorrect SELECT results
* must take collation into account
sql/item_cmpfunc.cc@stripped, 2006-07-13 15:55:07+03:00, gkodinov@stripped +4 -2
Bug #13311: IN + binary lead to incorrect SELECT results
* must take collation into account
sql/item_cmpfunc.h@stripped, 2006-07-13 15:55:08+03:00, gkodinov@stripped +1 -1
Bug #13311: IN + binary lead to incorrect SELECT results
* must take collation into account
sql/sql_select.cc@stripped, 2006-07-13 15:55:09+03:00, gkodinov@stripped +6 -4
Bug #13311: IN + binary lead to incorrect SELECT results
* must take collation into account
# 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: gkodinov
# Host: macbook.gmz
# Root: /Users/kgeorge/mysql/work/B13311-5.0-opt
--- 1.224/sql/item.cc 2006-07-13 15:55:35 +03:00
+++ 1.225/sql/item.cc 2006-07-13 15:55:35 +03:00
@@ -3700,7 +3700,7 @@
List_iterator_fast<Item_equal> li(cond_equal->current_level);
while ((item= li++))
{
- if (item->contains(field))
+ if (item->contains(this))
return item;
}
/*
--- 1.210/sql/item_cmpfunc.cc 2006-07-13 15:55:35 +03:00
+++ 1.211/sql/item_cmpfunc.cc 2006-07-13 15:55:35 +03:00
@@ -3771,13 +3771,15 @@
0 otherwise
*/
-bool Item_equal::contains(Field *field)
+bool Item_equal::contains(Item_field *field)
{
List_iterator_fast<Item_field> it(fields);
Item_field *item;
while ((item= it++))
{
- if (field->eq(item->field))
+ if (field->field->eq(item->field) &&
+ (field->result_type() != STRING_RESULT ||
+ collation.collation == item->collation.collation))
return 1;
}
return 0;
--- 1.128/sql/item_cmpfunc.h 2006-07-13 15:55:35 +03:00
+++ 1.129/sql/item_cmpfunc.h 2006-07-13 15:55:35 +03:00
@@ -1265,7 +1265,7 @@
void add(Item *c);
void add(Item_field *f);
uint members();
- bool contains(Field *field);
+ bool contains(Item_field *field);
Item_field* get_first() { return fields.head(); }
void merge(Item_equal *item);
void update_const();
--- 1.429/sql/sql_select.cc 2006-07-13 15:55:35 +03:00
+++ 1.430/sql/sql_select.cc 2006-07-13 15:55:35 +03:00
@@ -6211,7 +6211,7 @@
NULL - otherwise.
*/
-Item_equal *find_item_equal(COND_EQUAL *cond_equal, Field *field,
+Item_equal *find_item_equal(COND_EQUAL *cond_equal, Item_field *field,
bool *inherited_fl)
{
Item_equal *item= 0;
@@ -6353,9 +6353,11 @@
/* Search for multiple equalities containing field1 and/or field2 */
bool left_copyfl, right_copyfl;
Item_equal *left_item_equal=
- find_item_equal(cond_equal, left_field, &left_copyfl);
+ find_item_equal(cond_equal, (Item_field *) left_item,
+ &left_copyfl);
Item_equal *right_item_equal=
- find_item_equal(cond_equal, right_field, &right_copyfl);
+ find_item_equal(cond_equal, (Item_field *) right_item,
+ &right_copyfl);
if (left_item_equal && left_item_equal == right_item_equal)
{
@@ -6444,7 +6446,7 @@
}
Item_equal *item_equal = find_item_equal(cond_equal,
- field_item->field, ©fl);
+ field_item, ©fl);
if (copyfl)
{
item_equal= new Item_equal(item_equal);
--- 1.22/mysql-test/r/binary.result 2006-07-13 15:55:35 +03:00
+++ 1.23/mysql-test/r/binary.result 2006-07-13 15:55:35 +03:00
@@ -160,3 +160,15 @@
62000000000000000000
62200000000000000000
drop table t1;
+CREATE TABLE t1( a CHAR(20), b CHAR(20));
+INSERT INTO t1 VALUES ("john","doe"),("John","Doe");
+SELECT * FROM t1 WHERE a='john' AND a IN ( BINARY 'John', BINARY 'John');
+a b
+John Doe
+SELECT * FROM t1 WHERE a='john' AND a IN ( BINARY 'John', 'Doe');
+a b
+John Doe
+SELECT * FROM t1 WHERE a='john' AND BINARY 'John' IN (a,b);
+a b
+John Doe
+DROP TABLE t1;
--- 1.17/mysql-test/t/binary.test 2006-07-13 15:55:36 +03:00
+++ 1.18/mysql-test/t/binary.test 2006-07-13 15:55:36 +03:00
@@ -101,3 +101,13 @@
insert into t1 values ('b'),('b ');
select hex(col1) from t1;
drop table t1;
+
+#
+# Bug #13311: IN + binary lead to incorrect SELECT results
+#
+CREATE TABLE t1( a CHAR(20), b CHAR(20));
+INSERT INTO t1 VALUES ("john","doe"),("John","Doe");
+SELECT * FROM t1 WHERE a='john' AND a IN ( BINARY 'John', BINARY 'John');
+SELECT * FROM t1 WHERE a='john' AND a IN ( BINARY 'John', 'Doe');
+SELECT * FROM t1 WHERE a='john' AND BINARY 'John' IN (a,b);
+DROP TABLE t1;
| Thread |
|---|
| • bk commit into 5.0 tree (gkodinov:1.2209) BUG#13311 | kgeorge | 13 Jul |