From 676f986838bcf220ee50dc5df975b153eced76d1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Mar 2003 17:24:46 +0400 Subject: [PATCH] Produce an error when arguments are not compatible for CONCAT() --- sql/item.cc | 16 +++++++++------- sql/item_strfunc.cc | 8 ++++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index b28b390c4a0..f2053c37fb7 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -180,13 +180,10 @@ bool Item::set_charset(CHARSET_INFO *cs1, enum coercion co1, set_charset(&my_charset_bin, COER_NOCOLL); return 0; } - + if (!my_charset_same(cs1,cs2)) - { - set_charset(&my_charset_bin, COER_NOCOLL); - return 0; - } - + return 1; + if (co1 < co2) { set_charset(cs1, co1); @@ -198,7 +195,12 @@ bool Item::set_charset(CHARSET_INFO *cs1, enum coercion co1, else // co2 == co1 { if (cs1 != cs2) - set_charset(&my_charset_bin, COER_NOCOLL); + { + CHARSET_INFO *bin= get_charset_by_csname(cs1->csname, MY_CS_BINSORT,MYF(0)); + if (!bin) + return 1; + set_charset(bin, COER_NOCOLL); + } else set_charset(cs2, co2); } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 5151a25f257..d04ed97393d 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -328,8 +328,12 @@ void Item_func_concat::fix_length_and_dec() for (uint i=0 ; i < arg_count ; i++) { max_length+=args[i]->max_length; - set_charset(charset(), coercibility, - args[i]->charset(), args[i]->coercibility); + if (set_charset(charset(), coercibility, + args[i]->charset(), args[i]->coercibility)) + { + my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name()); + break; + } } if (max_length > MAX_BLOB_WIDTH)