From cd89ed9ab6ae511581471b1aaa640fadc3819f63 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Jan 2005 17:41:06 +0400 Subject: 1. Item now uses my_charset_bin by default, not default_charset_into. It fixes the problem that in some cases numbers where treated as CHAR(N), not as BINARY(N), e.g. wrong 'charsetnr' when sent to the client side. 2. IFNULL didn't aggregate argument charsets and collations, so IFNULL(1,'a') produced a CHAR(N). Now produces a BINARY(N). 3. SELECT PROCEDURE ANALIZE now returns BINARY columns, which is much better than it worked previously: CHAR with the default character set. But in the future it's worth to fix the fields 'Field_name' and 'Optimal_fieldtype' to use UTF8, and 'Min_value' and 'Max_value' to inherit their charsets from the original items. But it is not important, and BINARY(N) is OK for now. 4. Tests were fixed accordingly. No new tests were made, as the old onces cover everything. mysql-test/r/analyse.result: SELECT PROCEDURE ANALIZE now returns BINARY columns, which is much better than it worked previously: CHAR with the default character set. But in the future it's worth to fix the fields 'Field_name' and 'Optimal_fieldtype' to use UTF8, and 'Min_value' and 'Max_value' to inherit their charsets from the original items. But it is not important, and BINARY(N) is OK for now. mysql-test/r/case.result: Test fix according to the changes mysql-test/r/metadata.result: Test fix according to the changes mysql-test/r/ps_1general.result: Test fix according to the changes mysql-test/r/ps_2myisam.result: Test fix according to the changes mysql-test/r/ps_3innodb.result: Test fix according to the changes mysql-test/r/ps_4heap.result: Test fix according to the changes mysql-test/r/ps_5merge.result: Test fix according to the changes mysql-test/r/ps_6bdb.result: Test fix according to the changes mysql-test/r/ps_7ndb.result: Test fix according to the changes mysql-test/r/union.result: Test fix according to the changes sql/item.cc: Item is now BINARY by default sql/item_cmpfunc.cc: IFNULL now collects arguments collations/charsets like other functions do. --- sql/item_cmpfunc.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sql/item_cmpfunc.cc') diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 3d79c16b5d0..6ec98f2dcd4 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1094,6 +1094,9 @@ Item_func_nullif::fix_length_and_dec() max_length=args[0]->max_length; decimals=args[0]->decimals; agg_result_type(&cached_result_type, args, 2); + if (cached_result_type == STRING_RESULT && + agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV)) + return; } } -- cgit v1.2.1 From 9241e34593c94ec65920026d689b118355356c3a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Jan 2005 15:38:56 +0400 Subject: item_cmpfunc.cc: Bug#7834 Illegal mix of collations in IN operator IN was the first function supporting character set convertion. agg_arg_charsets() was written afterwards, which is more flexible. Now IN just reuses this function. sql/item_cmpfunc.cc: Bug#7834 Illegal mix of collations in IN operator IN was the first function supporting character set convertion. agg_arg_charsets() was written afterwards, which is more flexible. Now IN just reuses this function. --- sql/item_cmpfunc.cc | 59 ++++------------------------------------------------- 1 file changed, 4 insertions(+), 55 deletions(-) (limited to 'sql/item_cmpfunc.cc') diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 6ec98f2dcd4..c5e6d520ab7 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1749,64 +1749,13 @@ void Item_func_in::fix_length_and_dec() agg_cmp_type(&cmp_type, args, arg_count); + if (cmp_type == STRING_RESULT && + agg_arg_charsets(cmp_collation, args, arg_count, MY_COLL_CMP_CONV)) + return; + for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++) const_itm&= arg[0]->const_item(); - - if (cmp_type == STRING_RESULT) - { - /* - We allow consts character set conversion for - - item IN (const1, const2, const3, ...) - - if item is in a superset for all arguments, - and if it is a stong side according to coercibility rules. - - TODO: add covnersion for non-constant IN values - via creating Item_func_conv_charset(). - */ - - if (agg_arg_collations_for_comparison(cmp_collation, args, arg_count, - MY_COLL_ALLOW_SUPERSET_CONV)) - return; - if ((!my_charset_same(args[0]->collation.collation, - cmp_collation.collation) || !const_itm)) - { - if (agg_arg_collations_for_comparison(cmp_collation, args, arg_count)) - return; - } - else - { - /* - Conversion is possible: - All IN arguments are constants. - */ - Item_arena *arena, backup; - arena= thd->change_arena_if_needed(&backup); - - for (arg= args+1, arg_end= args+arg_count; arg < arg_end; arg++) - { - if (!arg[0]->null_value && - !my_charset_same(cmp_collation.collation, - arg[0]->collation.collation)) - { - Item_string *conv; - String tmp, cstr, *ostr= arg[0]->val_str(&tmp); - uint dummy_errors; - cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), - cmp_collation.collation, &dummy_errors); - conv= new Item_string(cstr.ptr(),cstr.length(), cstr.charset(), - arg[0]->collation.derivation); - conv->str_value.copy(); - arg[0]= conv; - } - } - if (arena) - thd->restore_backup_item_arena(arena, &backup); - } - } - /* Row item with NULLs inside can return NULL or FALSE => they can't be processed as static -- cgit v1.2.1