List:Commits« Previous MessageNext Message »
From:eugene Date:April 28 2006 11:39am
Subject:bk commit into 4.1 tree (evgen:1.2468) BUG#18630
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 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.2468 06/04/28 13:39:24 evgen@stripped +3 -0
  Fixed bug#18630: Incorrect type coercion in IN() results in false comparison
  
  The IN() function aggregates all types of its arguments to find out some
  general type for comparison purposes. This is reasonable when all function
  arguments are constants. But when the first argument is the field or an
  expression this can lead to false comarisons. In this case it's better to
  coerce constants to the type of the first argument.
  
  The Item_func_in::fix_len_and_dec() function now uses result type of its
  first argument as the comparison type is the first argument isn't a
  constant. Otherwise it finds out comparison type as usual.

  sql/item_cmpfunc.cc
    1.208 06/04/28 13:38:26 evgen@stripped +5 -2
    Fixed bug#18630: Incorrect type coercion in IN() results in false comparison.
    The Item_func_in::fix_len_and_dec() function now uses result type of its
    first argument as the comparison type is the first argument isn't a
    constant. Otherwise it finds out comparison type as usual.

  mysql-test/r/func_in.result
    1.17 06/04/28 13:38:01 evgen@stripped +7 -0
    Added test case for bug#18630: Incorrect type coercion in IN() results in false
comparison.

  mysql-test/t/func_in.test
    1.17 06/04/28 13:36:46 evgen@stripped +8 -0
    Added test case for bug#18630: Incorrect type coercion in IN() results in false
comparison.

# 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/18630-bug-4.1-mysql

--- 1.207/sql/item_cmpfunc.cc	2006-04-21 10:47:53 +04:00
+++ 1.208/sql/item_cmpfunc.cc	2006-04-28 13:38:26 +04:00
@@ -1924,8 +1924,11 @@
   Item **arg, **arg_end;
   uint const_itm= 1;
   THD *thd= current_thd;
-  
-  agg_cmp_type(&cmp_type, args, arg_count);
+
+  if (args[0]->const_item())
+    agg_cmp_type(&cmp_type, args, arg_count);
+  else
+    cmp_type= args[0]->result_type();
 
   if (cmp_type == STRING_RESULT &&
       agg_arg_charsets(cmp_collation, args, arg_count, MY_COLL_CMP_CONV))

--- 1.16/mysql-test/r/func_in.result	2005-09-23 13:43:16 +04:00
+++ 1.17/mysql-test/r/func_in.result	2006-04-28 13:38:01 +04:00
@@ -202,3 +202,10 @@
 count(*)
 1
 drop table t1;
+create table t1 (f1 char(1));
+insert into t1 values (1),('a'),('z');
+select * from t1 where f1 in (1,'z');
+f1
+1
+z
+drop table t1;

--- 1.16/mysql-test/t/func_in.test	2005-09-23 13:43:16 +04:00
+++ 1.17/mysql-test/t/func_in.test	2006-04-28 13:36:46 +04:00
@@ -109,4 +109,12 @@
 select count(*) from t1 where id not in (1,2);
 drop table t1;
 
+#
+# Bug#18630
+#
+create table t1 (f1 char(1));
+insert into t1 values (1),('a'),('z');
+select * from t1 where f1 in (1,'z');
+drop table t1;
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (evgen:1.2468) BUG#18630eugene28 Apr