MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:kgeorge Date:August 14 2006 3:35pm
Subject:bk commit into 5.0 tree (gkodinov:1.2235) BUG#21159
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-08-14 18:35:09+03:00, gkodinov@stripped +3 -0
  Bug #21159: Optimizer: wrong result after AND with different data types
  Disable const propagation for Item_hex_string.
  This must be done because Item_hex_string->val_int() is not
  the same as (Item_hex_string->val_str() in BINARY column)->val_int().
  We cannot simply disable the replacement in a particular context (
  e.g. <bin_col> = <int_col> AND <bin_col> = <hex_string>) since
  Items don't know the context they are in and there are functions like 
  IF (<hex_string>, 'yes', 'no').
  Note that this will disable some valid cases as well 
  (e.g. : <bin_col> = <hex_string> AND <bin_col2> = <bin_col>) but 
  there's no way to distinguish the valid cases without having the
  Item's parent say something like : Item->set_context(Item::STRING_RESULT)
  and have all the Items that contain other Items do that consistently.

  mysql-test/r/compare.result@stripped, 2006-08-14 18:35:01+03:00, gkodinov@stripped +7 -0
    Bug #21159: Optimizer: wrong result after AND with different data types
     - test case

  mysql-test/t/compare.test@stripped, 2006-08-14 18:35:02+03:00, gkodinov@stripped +9 -0
    Bug #21159: Optimizer: wrong result after AND with different data types
     - test case

  sql/sql_select.cc@stripped, 2006-08-14 18:35:02+03:00, gkodinov@stripped +16 -1
    Bug #21159: Optimizer: wrong result after AND with different data types
     - disable const propagation for Item_hex_string.

# 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/B21159-5.0-opt

--- 1.439/sql/sql_select.cc	2006-08-14 18:35:25 +03:00
+++ 1.440/sql/sql_select.cc	2006-08-14 18:35:25 +03:00
@@ -6498,8 +6498,23 @@ static bool check_equality(Item *item, C
         field_item= (Item_field*) right_item;
         const_item= left_item;
       }
+      /* 
+        Disable const propagation for Item_hex_string.
+        This must be done because Item_hex_string->val_int() is not
+        the same as (Item_hex_string->val_str() in BINARY column)->val_int().
+        We cannot simply disable the replacement in a particular context (
+        e.g. <bin_col> = <int_col> AND <bin_col> = <hex_string>) since
+        Items don't know the context they are in and there are functions like 
+        IF (<hex_string>, 'yes', 'no').
+        Note that this will disable some valid cases as well 
+        (e.g. : <bin_col> = <hex_string> AND <bin_col2> = <bin_col>) but 
+        there's no way to distinguish the valid cases without having the
+        Item's parent say something like : Item->set_context(Item::STRING_RESULT)
+        and have all the Items that contain other Items do that consistently.
+      */
       if (const_item &&
-          field_item->result_type() == const_item->result_type())
+          field_item->result_type() == const_item->result_type() &&
+          const_item->type() != Item::VARBIN_ITEM)
       {
         bool copyfl;
 

--- 1.10/mysql-test/r/compare.result	2006-08-14 18:35:25 +03:00
+++ 1.11/mysql-test/r/compare.result	2006-08-14 18:35:25 +03:00
@@ -42,3 +42,10 @@ CHAR(31) = ''	'' = CHAR(31)
 SELECT CHAR(30) = '', '' = CHAR(30);
 CHAR(30) = ''	'' = CHAR(30)
 0	0
+create table t1 (a tinyint(1),b binary(1));
+insert into t1 values (0x01,0x01);
+select * from t1 where a=b;
+a	b
+select * from t1 where a=b and b=0x01;
+a	b
+drop table if exists t1;

--- 1.9/mysql-test/t/compare.test	2006-08-14 18:35:25 +03:00
+++ 1.10/mysql-test/t/compare.test	2006-08-14 18:35:25 +03:00
@@ -37,3 +37,12 @@ SELECT CHAR(31) = '', '' = CHAR(31);
 SELECT CHAR(30) = '', '' = CHAR(30);
 
 # End of 4.1 tests
+
+#
+#Bug #21159: Optimizer: wrong result after AND with different data types
+#
+create table t1 (a tinyint(1),b binary(1));
+insert into t1 values (0x01,0x01);
+select * from t1 where a=b;
+select * from t1 where a=b and b=0x01;
+drop table if exists t1;
Thread
bk commit into 5.0 tree (gkodinov:1.2235) BUG#21159kgeorge14 Aug