--- mysql-5.0-orig/sql/sql_string.h Mon Jan 22 12:10:41 2007 +++ mysql-5.0-ucs/sql/sql_string.h Thu Jun 7 01:07:02 2007 @@ -244,6 +244,7 @@ bool set_or_copy_aligned(const char *s, uint32 arg_length, CHARSET_INFO *cs); bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom, CHARSET_INFO *csto, uint *errors); + bool convert_cs(CHARSET_INFO *cs); bool append(const String &s); bool append(const char *s); bool append(const char *s,uint32 arg_length); --- mysql-5.0-orig/sql/sql_string.cc Mon Jan 22 12:10:41 2007 +++ mysql-5.0-ucs/sql/sql_string.cc Thu Jun 7 02:18:35 2007 @@ -414,6 +414,26 @@ str_length--; } +bool String::convert_cs(CHARSET_INFO *cs) +{ + uint32 offset; + if (needs_conversion(str_length, str_charset, cs, &offset)) + { + String tmp; + uint32 new_length= str_length / str_charset->mbminlen * cs->mbmaxlen; + uint dummy_errors; + tmp.copy(*this); + if (realloc(new_length)) + return TRUE; + str_length= copy_and_convert(Ptr, new_length, cs, + tmp.Ptr, str_length, str_charset, + &dummy_errors); + } + + str_charset= cs; + return FALSE; +} + bool String::append(const String &s) { if (s.length()) --- mysql-5.0-orig/sql/item_sum.cc Tue May 22 13:45:56 2007 +++ mysql-5.0-ucs/sql/item_sum.cc Thu Jun 7 01:46:17 2007 @@ -3209,6 +3209,9 @@ null_value= 1; max_length= thd->variables.group_concat_max_len; + if (separator->convert_cs(collation.collation)) + return TRUE; + if (check_sum_func(thd, ref)) return TRUE; --- mysql-5.0-orig/sql/sql_yacc.yy Tue Jun 5 22:04:34 2007 +++ mysql-5.0-ucs/sql/sql_yacc.yy Thu Jun 7 03:08:52 2007 @@ -5420,7 +5420,7 @@ |DISTINCT { $$ = 1; }; opt_gconcat_separator: - /* empty */ { $$ = new (YYTHD->mem_root) String(",",1,default_charset_info); } + /* empty */ { $$ = new (YYTHD->mem_root) String(",", 1, &my_charset_latin1); } |SEPARATOR_SYM text_string { $$ = $2; }; --- mysql-5.0-orig/mysql-test/t/func_gconcat.test Tue May 22 13:48:47 2007 +++ mysql-5.0-ucs/mysql-test/t/func_gconcat.test Thu Jun 7 03:16:31 2007 @@ -552,3 +552,17 @@ DROP TABLE t1, t2, t3; --echo End of 5.0 tests + +create table t1 (a char(1) character set ucs2); +insert into t1 values ('a'),('b'),('c'); +select hex(group_concat(a)) from t1; +select collation(group_concat(a)) from t1; +DROP TABLE t1; + +set names latin1; +create table t1 (a char(1) character set latin1); +insert into t1 values ('a'),('b'),('c'); +set character_set_connection=ucs2; +select hex(group_concat(a separator ',')) from t1; +select collation(group_concat(a separator ',')) from t1; +drop table t1; --- mysql-5.0-orig/mysql-test/r/func_gconcat.result Tue May 22 13:48:47 2007 +++ mysql-5.0-ucs/mysql-test/r/func_gconcat.result Thu Jun 7 03:16:44 2007 @@ -811,3 +811,23 @@ SET group_concat_max_len= DEFAULT; DROP TABLE t1, t2, t3; End of 5.0 tests +create table t1 (a char(1) character set ucs2); +insert into t1 values ('a'),('b'),('c'); +select hex(group_concat(a)) from t1; +hex(group_concat(a)) +0061002C0062002C0063 +select collation(group_concat(a)) from t1; +collation(group_concat(a)) +ucs2_general_ci +DROP TABLE t1; +set names latin1; +create table t1 (a char(1) character set latin1); +insert into t1 values ('a'),('b'),('c'); +set character_set_connection=ucs2; +select hex(group_concat(a separator ',')) from t1; +hex(group_concat(a separator ',')) +612C622C63 +select collation(group_concat(a separator ',')) from t1; +collation(group_concat(a separator ',')) +latin1_swedish_ci +drop table t1;