From 687863c093f0f01f54770b10fdd40f554e21a6f8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Jul 2003 14:03:54 +0500 Subject: [PATCH] IN now aggregates all argument types for comparison --- mysql-test/r/func_in.result | 21 +++++++++++++++++++++ mysql-test/t/func_in.test | 8 ++++++++ sql/item_cmpfunc.cc | 7 ++++--- sql/item_cmpfunc.h | 1 + 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index 4b15c44fdb1..a197371b345 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -143,3 +143,24 @@ select * from t1 where 'a' in (a,b,c collate latin1_bin); a b c a c c drop table t1; +select '1.0' in (1,2); +'1.0' in (1,2) +1 +select 1 in ('1.0',2); +1 in ('1.0',2) +1 +select 1 in (1,'2.0'); +1 in (1,'2.0') +1 +select 1 in ('1.0',2.0); +1 in ('1.0',2.0) +1 +select 1 in (1.0,'2.0'); +1 in (1.0,'2.0') +1 +select 1 in ('1.1',2); +1 in ('1.1',2) +0 +select 1 in ('1.1',2.0); +1 in ('1.1',2.0) +0 diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index dca068f368a..105612bf238 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -73,3 +73,11 @@ select * from t1 where 'a' collate latin1_general_ci in (a,b,c); select * from t1 where 'a' collate latin1_bin in (a,b,c); select * from t1 where 'a' in (a,b,c collate latin1_bin); drop table t1; + +select '1.0' in (1,2); +select 1 in ('1.0',2); +select 1 in (1,'2.0'); +select 1 in ('1.0',2.0); +select 1 in (1.0,'2.0'); +select 1 in ('1.1',2); +select 1 in ('1.1',2.0); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index cb7c2cb0198..78ec253c7a2 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1405,7 +1405,8 @@ void Item_func_in::fix_length_and_dec() Item **arg, **arg_end; uint const_itm= 1; - if ((args[0]->result_type() == STRING_RESULT) && + agg_cmp_type(&cmp_type, args, arg_count); + if ((cmp_type == STRING_RESULT) && (agg_arg_collations_for_comparison(cmp_collation, args, arg_count))) return; @@ -1418,7 +1419,7 @@ void Item_func_in::fix_length_and_dec() */ if (const_itm && !nulls_in_row()) { - switch (args[0]->result_type()) { + switch (cmp_type) { case STRING_RESULT: uint i; array=new in_string(arg_count-1,(qsort2_cmp) srtcmp_in, @@ -1452,7 +1453,7 @@ void Item_func_in::fix_length_and_dec() else { in_item= cmp_item::get_comparator(args[0]); - if (args[0]->result_type() == STRING_RESULT) + if (cmp_type == STRING_RESULT) in_item->cmp_charset= cmp_collation.collation; } maybe_null= args[0]->maybe_null; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index a9fba76a7b8..25cc97d60bf 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -611,6 +611,7 @@ public: class Item_func_in :public Item_int_func { + Item_result cmp_type; in_vector *array; cmp_item *in_item; bool have_null;