From 66631a3c1eb3a774042f1cd36372bf3c389ce69b Mon Sep 17 00:00:00 2001 From: "bar@bar.intranet.mysql.r18.ru" <> Date: Fri, 19 Mar 2004 12:09:14 +0400 Subject: [PATCH] Bug #3087 CONCAT_WS makes the server die in case of illegal mix of collations --- mysql-test/r/func_str.result | 2 ++ mysql-test/t/func_str.test | 2 ++ sql/item_strfunc.cc | 2 ++ 3 files changed, 6 insertions(+) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 86c4b8cf0dc..d3225679b3e 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -339,6 +339,8 @@ select concat(_latin1'a',_latin2'a',_latin5'a'); ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin5_turkish_ci,COERCIBLE) for operation 'concat' select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a'); ERROR HY000: Illegal mix of collations for operation 'concat' +select concat_ws(_latin1'a',_latin2'a'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat_ws' select FIELD('b','A','B'); FIELD('b','A','B') 2 diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 1e6d279f721..1c85f83baac 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -195,6 +195,8 @@ select concat(_latin1'a',_latin2'a'); select concat(_latin1'a',_latin2'a',_latin5'a'); --error 1271 select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a'); +--error 1267 +select concat_ws(_latin1'a',_latin2'a'); # # Test FIELD() and collations diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 2833e1ca016..06131950ec3 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -628,9 +628,11 @@ void Item_func_concat_ws::fix_length_and_dec() max_length=separator->max_length*(arg_count-1); for (uint i=0 ; i < arg_count ; i++) { + DTCollation tmp(collation.collation, collation.derivation); max_length+=args[i]->max_length; if (collation.aggregate(args[i]->collation)) { + collation.set(tmp); // Restore the previous value my_coll_agg_error(collation, args[i]->collation, func_name()); break; }