MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:bar Date:June 7 2007 8:43am
Subject:bk commit into 5.1 tree (bar:1.2546)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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-07 13:43:20+05:00, bar@stripped +4 -0
  Merge mysql.com:/home/bar/mysql-work/mysql-5.0.b26711
  into  mysql.com:/home/bar/mysql-work/mysql-5.1.b26711
  MERGE: 1.1810.2943.38

  sql/sql_class.cc@stripped, 2007-06-07 13:43:16+05:00, bar@stripped +0 -0
    Auto merged
    MERGE: 1.223.1.48

  strings/ctype-big5.c@stripped, 2007-06-07 13:43:16+05:00, bar@stripped +0 -0
    Auto merged
    MERGE: 1.80.1.12

  strings/ctype-gbk.c@stripped, 2007-06-07 13:43:17+05:00, bar@stripped +0 -0
    Auto merged
    MERGE: 1.78.1.4

  strings/ctype-sjis.c@stripped, 2007-06-07 13:43:17+05:00, bar@stripped +0 -0
    Auto merged
    MERGE: 1.88.1.6

# 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.1.b26711/RESYNC

--- 1.338/sql/sql_class.cc	2007-06-05 04:15:01 +05:00
+++ 1.339/sql/sql_class.cc	2007-06-07 13:43:16 +05:00
@@ -1456,6 +1456,11 @@
 }
 
 
+#define NEED_ESCAPING(x) ((int) (uchar) (x) == escape_char    || \
+                          (int) (uchar) (x) == field_sep_char || \
+                          (int) (uchar) (x) == line_sep_char  || \
+                          !(x))
+
 bool select_export::send_data(List<Item> &items)
 {
 
@@ -1515,14 +1520,20 @@
 	used_length=res->length();
       if (result_type == STRING_RESULT && escape_char != -1)
       {
-	char *pos,*start,*end;
-
+        char *pos, *start, *end;
+        CHARSET_INFO *res_charset= res->charset();
+        CHARSET_INFO *character_set_client= thd->variables.
+                                            character_set_client;
+        bool check_second_byte= (res_charset == &my_charset_bin) &&
+                                 character_set_client->
+                                 escape_with_backslash_is_dangerous;
+        DBUG_ASSERT(character_set_client->mbmaxlen == 2 ||
+                    !character_set_client->escape_with_backslash_is_dangerous);
 	for (start=pos=(char*) res->ptr(),end=pos+used_length ;
 	     pos != end ;
 	     pos++)
 	{
 #ifdef USE_MB
-          CHARSET_INFO *res_charset=res->charset();
 	  if (use_mb(res_charset))
 	  {
 	    int l;
@@ -1533,9 +1544,45 @@
 	    }
 	  }
 #endif
-	  if ((int) *pos == escape_char || (int) *pos == field_sep_char ||
-	      (int) *pos == line_sep_char || !*pos)
-	  {
+
+          /*
+            Special case when dumping BINARY/VARBINARY/BLOB values
+            for the clients with character sets big5, cp932, gbk and sjis,
+            which can have the escape character (0x5C "\" by default)
+            as the second byte of a multi-byte sequence.
+            
+            If
+            - pos[0] is a valid multi-byte head (e.g 0xEE) and
+            - pos[1] is 0x00, which will be escaped as "\0",
+            
+            then we'll get "0xEE + 0x5C + 0x30" in the output file.
+            
+            If this file is later loaded using this sequence of commands:
+            
+            mysql> create table t1 (a varchar(128)) character set big5;
+            mysql> LOAD DATA INFILE 'dump.txt' INTO TABLE t1;
+            
+            then 0x5C will be misinterpreted as the second byte
+            of a multi-byte character "0xEE + 0x5C", instead of
+            escape character for 0x00.
+            
+            To avoid this confusion, we'll escape the multi-byte
+            head character too, so the sequence "0xEE + 0x00" will be
+            dumped as "0x5C + 0xEE + 0x5C + 0x30".
+            
+            Note, in the condition below we only check if
+            mbcharlen is equal to 2, because there are no
+            character sets with mbmaxlen longer than 2
+            and with escape_with_backslash_is_dangerous set.
+            DBUG_ASSERT before the loop makes that sure.
+          */
+
+          if (NEED_ESCAPING(*pos) ||
+              (check_second_byte &&
+               my_mbcharlen(character_set_client, (uchar) *pos) == 2 &&
+               pos + 1 < end &&
+               NEED_ESCAPING(pos[1])))
+          {
 	    char tmp_buff[2];
 	    tmp_buff[0]= escape_char;
 	    tmp_buff[1]= *pos ? *pos : '0';

--- 1.92/strings/ctype-big5.c	2007-05-10 14:59:34 +05:00
+++ 1.93/strings/ctype-big5.c	2007-06-07 13:43:16 +05:00
@@ -6402,7 +6402,7 @@
     0,			/* min_sort_char */
     255,		/* max_sort_char */
     ' ',                /* pad char      */
-    0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* escape_with_backslash_is_dangerous */
     &my_charset_big5_handler,
     &my_collation_big5_chinese_ci_handler
 };
@@ -6435,7 +6435,7 @@
     0,			/* min_sort_char */
     255,		/* max_sort_char */
     ' ',                /* pad char      */
-    0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* escape_with_backslash_is_dangerous */
     &my_charset_big5_handler,
     &my_collation_mb_bin_handler
 };

--- 1.83/strings/ctype-gbk.c	2007-05-10 14:59:34 +05:00
+++ 1.84/strings/ctype-gbk.c	2007-06-07 13:43:17 +05:00
@@ -10048,7 +10048,7 @@
     0,			/* min_sort_char */
     255,		/* max_sort_char */
     ' ',                /* pad char      */
-    0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* escape_with_backslash_is_dangerous */
     &my_charset_handler,
     &my_collation_ci_handler
 };
@@ -10080,7 +10080,7 @@
     0,			/* min_sort_char */
     255,		/* max_sort_char */
     ' ',                /* pad char      */
-    0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* escape_with_backslash_is_dangerous */
     &my_charset_handler,
     &my_collation_mb_bin_handler
 };

--- 1.94/strings/ctype-sjis.c	2007-05-10 14:59:34 +05:00
+++ 1.95/strings/ctype-sjis.c	2007-06-07 13:43:17 +05:00
@@ -4696,7 +4696,7 @@
     0,			/* min_sort_char */
     255,		/* max_sort_char */
     ' ',                /* pad char      */
-    0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* escape_with_backslash_is_dangerous */
     &my_charset_handler,
     &my_collation_ci_handler
 };
@@ -4728,7 +4728,7 @@
     0,			/* min_sort_char */
     255,		/* max_sort_char */
     ' ',                /* pad char      */
-    0,                  /* escape_with_backslash_is_dangerous */
+    1,                  /* escape_with_backslash_is_dangerous */
     &my_charset_handler,
     &my_collation_mb_bin_handler
 };
Thread
bk commit into 5.1 tree (bar:1.2546)bar7 Jun