MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:bar Date:June 8 2007 8:04am
Subject:bk commit into 5.0 tree (bar:1.2516) BUG#28925
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of bar. When bar does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-06-08 13:04:51+05:00, bar@stripped +9 -0
  Bug#28925 GROUP_CONCAT inserts wrong separators for a ucs2 column
  Problem: separator was not converted to the result character set,
  so the result was a mixture of two different character sets,
  which was especially bad for UCS2.
  Fix: convert separator to the result character set.
  
  Many thanks for Martin Friebe for helping us again.

  mysql-test/r/ctype_ucs.result@stripped, 2007-06-08 13:04:50+05:00, bar@stripped +21 -0
    Adding test case

  mysql-test/r/ctype_ucs2_def.result@stripped, 2007-06-08 13:04:50+05:00, bar@stripped +8 -0
    Adding test case

  mysql-test/t/ctype_ucs.test@stripped, 2007-06-08 13:04:50+05:00, bar@stripped +18 -0
    Adding test case

  mysql-test/t/ctype_ucs2_def.test@stripped, 2007-06-08 13:04:50+05:00, bar@stripped +13 -0
    Adding test case

  sql/item_sum.cc@stripped, 2007-06-08 13:04:50+05:00, bar@stripped +2 -1
    Adding conversion of separator to the result character set

  sql/item_sum.h@stripped, 2007-06-08 13:04:50+05:00, bar@stripped +8 -1
    Free converted string.

  sql/sql_string.cc@stripped, 2007-06-08 13:04:50+05:00, bar@stripped +24 -0
    Adding new method, to convert String to another character set.

  sql/sql_string.h@stripped, 2007-06-08 13:04:50+05:00, bar@stripped +1 -0
    Adding prototype for the new String method.

  sql/sql_yacc.yy@stripped, 2007-06-08 13:04:50+05:00, bar@stripped +5 -2
    Fixing GROUPC_CONCAT problems when "mysqld --default-character-set=ucs2".

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	bar
# Host:	bar.myoffice.izhnet.ru
# Root:	/home/bar/mysql-work/mysql-5.0.b28925

--- 1.208/sql/item_sum.cc	2007-05-22 17:45:56 +05:00
+++ 1.209/sql/item_sum.cc	2007-06-08 13:04:50 +05:00
@@ -3209,7 +3209,8 @@
   null_value= 1;
   max_length= thd->variables.group_concat_max_len;
 
-  if (check_sum_func(thd, ref))
+  if (separator->convert_charset(collation.collation) ||
+      check_sum_func(thd, ref))
     return TRUE;
 
   fixed= 1;

--- 1.112/sql/item_sum.h	2007-03-23 01:48:00 +04:00
+++ 1.113/sql/item_sum.h	2007-06-08 13:04:50 +05:00
@@ -1200,7 +1200,14 @@
                          SQL_LIST *is_order, String *is_separator);
 
   Item_func_group_concat(THD *thd, Item_func_group_concat *item);
-  ~Item_func_group_concat() {}
+  ~Item_func_group_concat()
+  {
+    /*
+      We need this if separator was convered
+      to another character set.
+    */
+    separator->free();
+  }
   void cleanup();
 
   enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;}

--- 1.97/sql/sql_string.cc	2007-01-22 16:10:41 +04:00
+++ 1.98/sql/sql_string.cc	2007-06-08 13:04:50 +05:00
@@ -361,6 +361,30 @@
 }
 
 
+/**
+   @brief Convert String to the given character set
+   
+   @details Copy String to itself with character set conversion.
+   
+   @return Operation status
+   @retval FALSE      success.
+   @retval TRUE       error occurred.
+*/
+bool String::convert_charset(CHARSET_INFO *cs)
+{
+  uint32 offset;
+  if (needs_conversion(str_length, str_charset, cs, &offset))
+  {
+    String tmp;
+    uint dummy_errors;
+    return tmp.copy(*this) ||
+           copy(tmp.ptr(), tmp.length(), tmp.charset(), cs, &dummy_errors);
+  }
+  str_charset= cs;
+  return FALSE;
+}
+
+
 /*
   Set a string to the value of a latin1-string, keeping the original charset
   

--- 1.66/sql/sql_string.h	2007-01-22 16:10:41 +04:00
+++ 1.67/sql/sql_string.h	2007-06-08 13:04:50 +05:00
@@ -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_charset(CHARSET_INFO *cs);
   bool append(const String &s);
   bool append(const char *s);
   bool append(const char *s,uint32 arg_length);

--- 1.521/sql/sql_yacc.yy	2007-06-03 12:03:14 +05:00
+++ 1.522/sql/sql_yacc.yy	2007-06-08 13:04:50 +05:00
@@ -5420,8 +5420,11 @@
     |DISTINCT   { $$ = 1; };
 
 opt_gconcat_separator:
-    /* empty */        { $$ = new (YYTHD->mem_root) String(",",1,default_charset_info); }
-    |SEPARATOR_SYM text_string  { $$ = $2; };
+    /* empty */
+      {
+        $$= new (YYTHD->mem_root) String(",", 1, &my_charset_latin1);
+      }
+    | SEPARATOR_SYM text_string { $$ = $2; };
 
 
 opt_gorder_clause:

--- 1.51/mysql-test/r/ctype_ucs.result	2007-03-28 18:57:27 +05:00
+++ 1.52/mysql-test/r/ctype_ucs.result	2007-06-08 13:04:50 +05:00
@@ -865,4 +865,25 @@
 text	65535	65535
 text	65535	32767
 drop table t1;
+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;
+set names latin1;
 End of 5.0 tests

--- 1.50/mysql-test/t/ctype_ucs.test	2007-03-28 18:57:27 +05:00
+++ 1.51/mysql-test/t/ctype_ucs.test	2007-06-08 13:04:50 +05:00
@@ -594,4 +594,22 @@
   from information_schema.columns where table_name='t1';
 drop table t1;
 
+#
+# Bug#28925 GROUP_CONCAT inserts wrong separators for a ucs2 column
+#
+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;
+set names latin1;
+
 --echo End of 5.0 tests

--- 1.3/mysql-test/r/ctype_ucs2_def.result	2006-08-21 19:10:39 +05:00
+++ 1.4/mysql-test/r/ctype_ucs2_def.result	2007-06-08 13:04:50 +05:00
@@ -7,3 +7,11 @@
 DROP TABLE IF EXISTS t1;
 create table t1 (a int);
 drop table t1;
+End of 4.1 tests
+create table t1 (a char(1) character set latin1);
+insert into t1 values ('a'),('b'),('c');
+select hex(group_concat(a)) from t1;
+hex(group_concat(a))
+612C622C63
+drop table t1;
+End of 5.0 tests

--- 1.4/mysql-test/t/ctype_ucs2_def.test	2007-02-19 14:57:02 +04:00
+++ 1.5/mysql-test/t/ctype_ucs2_def.test	2007-06-08 13:04:50 +05:00
@@ -14,3 +14,16 @@
 --enable_warnings
 create table t1 (a int);
 drop table t1;
+
+--echo End of 4.1 tests
+
+#
+# Bug #28925 GROUP_CONCAT inserts wrong separators for a ucs2 column
+# Check that GROUP_CONCAT works fine with --default-character-set=ucs2
+#
+create table t1 (a char(1) character set latin1);
+insert into t1 values ('a'),('b'),('c');
+select hex(group_concat(a)) from t1;
+drop table t1;
+
+--echo End of 5.0 tests
Thread
bk commit into 5.0 tree (bar:1.2516) BUG#28925bar8 Jun