MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:kgeorge Date:July 17 2006 1:07pm
Subject:bk commit into 5.0 tree (gkodinov:1.2209) BUG#13311
View as plain text  
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-17 16:07:17+03:00, gkodinov@stripped +3 -0
  Bug #13311: IN + binary lead to incorrect SELECT results
   Don't substitute const equalities in IN if the collation is binary, eg
   ... WHERE a = 'val' AND a IN (BINARY 'VAL', ...) ...
   must not become 
   ... WHERE 'val' IN (BINARY 'VAL', ...) ...

  mysql-test/r/binary.result@stripped, 2006-07-17 16:06:56+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-17 16:06:58+03:00, gkodinov@stripped +10 -0
    Bug #13311: IN + binary lead to incorrect SELECT results
     * testsuite for the bug

  sql/item_cmpfunc.cc@stripped, 2006-07-17 16:06:59+03:00, gkodinov@stripped +14 -0
    Bug #13311: IN + binary lead to incorrect SELECT results
     * don't substitute constant equalities in IN predicate arguments 
       if the comparison collation is binary

# 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.210/sql/item_cmpfunc.cc	2006-07-17 16:07:40 +03:00
+++ 1.211/sql/item_cmpfunc.cc	2006-07-17 16:07:40 +03:00
@@ -2546,6 +2546,20 @@
     if (cmp_type  == STRING_RESULT)
       in_item->cmp_charset= cmp_collation.collation;
   }
+  if (cmp_collation.collation == &my_charset_bin)
+  {
+    /*
+      As this is binary compassion, mark all fields that they can't be
+      transformed. Otherwise we would get into trouble with comparisons
+      like:
+      WHERE col= 'j' AND col IN (BINARY 'j', ..)
+      which would be transformed to:
+      WHERE 'j' IN (BINARY 'j', ...)
+    */
+    for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++)
+      (*arg)->transform(&Item::set_no_const_sub, (byte*) 0);
+  }
+
   maybe_null= args[0]->maybe_null;
   max_length= 1;
 }

--- 1.22/mysql-test/r/binary.result	2006-07-17 16:07:40 +03:00
+++ 1.23/mysql-test/r/binary.result	2006-07-17 16:07:40 +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-17 16:07:40 +03:00
+++ 1.18/mysql-test/t/binary.test	2006-07-17 16:07:40 +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#13311kgeorge17 Jul