Loading mysql-test/r/func_in.result +21 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,27 @@ select count(*) from t1 where id not in (1,2); count(*) 1 drop table t1; create table t1 (f1 char(1), f2 int); insert into t1 values (1,0),('a',1),('z',2); select f1 from t1 where f1 in (1,'z'); f1 1 z select f2 from t1 where f2 in (1,'z'); f2 0 1 select f1 from t1 where 'z' in (1,f1); f1 z select * from t1 where 'z' in (f2,f1); f1 f2 z 2 select * from t1 where 1 in (f2,f1); f1 f2 1 0 a 1 drop table t1; CREATE TABLE t1 (a int PRIMARY KEY); INSERT INTO t1 VALUES (44), (45), (46); SELECT * FROM t1 WHERE a IN (45); Loading mysql-test/t/func_in.test +12 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,18 @@ select count(*) from t1 where id not in (1); select count(*) from t1 where id not in (1,2); drop table t1; # # Bug#18360 Incorrect type coercion in IN() results in false comparison # create table t1 (f1 char(1), f2 int); insert into t1 values (1,0),('a',1),('z',2); select f1 from t1 where f1 in (1,'z'); select f2 from t1 where f2 in (1,'z'); select f1 from t1 where 'z' in (1,f1); select * from t1 where 'z' in (f2,f1); select * from t1 where 1 in (f2,f1); drop table t1; # End of 4.1 tests # Loading sql/item_cmpfunc.cc +12 −4 Original line number Diff line number Diff line Loading @@ -76,11 +76,19 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) field= NULL; type[0]= items[0]->result_type(); /* Reset to 0 on first occurence of non-const item. 1 otherwise */ bool is_const= items[0]->const_item(); for (i= 1 ; i < nitems ; i++) { if (!items[i]->const_item()) { type[0]= is_const ? items[i]->result_type() : item_cmp_type(type[0], items[i]->result_type()); is_const= 0; } else if (is_const) type[0]= item_cmp_type(type[0], items[i]->result_type()); if (field && convert_constant_item(thd, field, &items[i])) type[0]= INT_RESULT; } } Loading Loading
mysql-test/r/func_in.result +21 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,27 @@ select count(*) from t1 where id not in (1,2); count(*) 1 drop table t1; create table t1 (f1 char(1), f2 int); insert into t1 values (1,0),('a',1),('z',2); select f1 from t1 where f1 in (1,'z'); f1 1 z select f2 from t1 where f2 in (1,'z'); f2 0 1 select f1 from t1 where 'z' in (1,f1); f1 z select * from t1 where 'z' in (f2,f1); f1 f2 z 2 select * from t1 where 1 in (f2,f1); f1 f2 1 0 a 1 drop table t1; CREATE TABLE t1 (a int PRIMARY KEY); INSERT INTO t1 VALUES (44), (45), (46); SELECT * FROM t1 WHERE a IN (45); Loading
mysql-test/t/func_in.test +12 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,18 @@ select count(*) from t1 where id not in (1); select count(*) from t1 where id not in (1,2); drop table t1; # # Bug#18360 Incorrect type coercion in IN() results in false comparison # create table t1 (f1 char(1), f2 int); insert into t1 values (1,0),('a',1),('z',2); select f1 from t1 where f1 in (1,'z'); select f2 from t1 where f2 in (1,'z'); select f1 from t1 where 'z' in (1,f1); select * from t1 where 'z' in (f2,f1); select * from t1 where 1 in (f2,f1); drop table t1; # End of 4.1 tests # Loading
sql/item_cmpfunc.cc +12 −4 Original line number Diff line number Diff line Loading @@ -76,11 +76,19 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) field= NULL; type[0]= items[0]->result_type(); /* Reset to 0 on first occurence of non-const item. 1 otherwise */ bool is_const= items[0]->const_item(); for (i= 1 ; i < nitems ; i++) { if (!items[i]->const_item()) { type[0]= is_const ? items[i]->result_type() : item_cmp_type(type[0], items[i]->result_type()); is_const= 0; } else if (is_const) type[0]= item_cmp_type(type[0], items[i]->result_type()); if (field && convert_constant_item(thd, field, &items[i])) type[0]= INT_RESULT; } } Loading