List:Internals« Previous MessageNext Message »
From:bar Date:December 6 2004 5:33pm
Subject:bk commit into 4.1 tree (bar:1.2137)
View as plain text  
Below is the list of changes that have just been committed into a local
4.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://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
  1.2137 04/12/06 20:33:16 bar@stripped +8 -0
  UCS2 support in ENUM and SET, which also fixes:
  Bug #5174 SHOW CREATE TABLE hangs up if the table contains half-with katakana enum
values
  UCS2 values are stored in HEX encoding in FRM file

  sql/unireg.cc
    1.44 04/12/06 20:33:12 bar@stripped +22 -0
    UCS2 support in ENUM and SET, which also fixes:
    Bug #5174 SHOW CREATE TABLE hangs up if the table contains half-with katakana enum
values
    UCS2 values are stored in HEX encoding in FRM file

  sql/table.cc
    1.118 04/12/06 20:33:12 bar@stripped +17 -0
    UCS2 support in ENUM and SET, which also fixes:
    Bug #5174 SHOW CREATE TABLE hangs up if the table contains half-with katakana enum
values
    UCS2 values are stored in HEX encoding in FRM file

  sql/strfunc.cc
    1.5 04/12/06 20:33:12 bar@stripped +17 -3
    UCS2 support in ENUM and SET, which also fixes:
    Bug #5174 SHOW CREATE TABLE hangs up if the table contains half-with katakana enum
values
    UCS2 values are stored in HEX encoding in FRM file

  sql/mysql_priv.h
    1.331 04/12/06 20:33:12 bar@stripped +17 -0
    UCS2 support in ENUM and SET, which also fixes:
    Bug #5174 SHOW CREATE TABLE hangs up if the table contains half-with katakana enum
values
    UCS2 values are stored in HEX encoding in FRM file

  sql/item_strfunc.cc
    1.199 04/12/06 20:33:12 bar@stripped +0 -11
    UCS2 support in ENUM and SET, which also fixes:
    Bug #5174 SHOW CREATE TABLE hangs up if the table contains half-with katakana enum
values
    UCS2 values are stored in HEX encoding in FRM file

  sql/field.cc
    1.207 04/12/06 20:33:12 bar@stripped +10 -9
    UCS2 support in ENUM and SET, which also fixes:
    Bug #5174 SHOW CREATE TABLE hangs up if the table contains half-with katakana enum
values
    UCS2 values are stored in HEX encoding in FRM file

  mysql-test/t/ctype_ucs.test
    1.17 04/12/06 20:33:12 bar@stripped +31 -0
    UCS2 support in ENUM and SET, which also fixes:
    Bug #5174 SHOW CREATE TABLE hangs up if the table contains half-with katakana enum
values
    UCS2 values are stored in HEX encoding in FRM file

  mysql-test/r/ctype_ucs.result
    1.18 04/12/06 20:33:12 bar@stripped +56 -0
    UCS2 support in ENUM and SET, which also fixes:
    Bug #5174 SHOW CREATE TABLE hangs up if the table contains half-with katakana enum
values
    UCS2 values are stored in HEX encoding in FRM file

# 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.intranet.mysql.r18.ru
# Root:	/usr/home/bar/mysql-4.1-set

--- 1.206/sql/field.cc	2004-12-06 16:22:47 +04:00
+++ 1.207/sql/field.cc	2004-12-06 20:33:12 +04:00
@@ -5529,8 +5529,7 @@
   }
 
   /* Remove end space */
-  while (length > 0 && my_isspace(system_charset_info,from[length-1]))
-    length--;
+  length= field_charset->cset->lengthsp(field_charset, from, length);
   uint tmp=find_type2(typelib, from, length, field_charset);
   if (!tmp)
   {
@@ -5632,7 +5631,7 @@
     val_ptr->set("", 0, field_charset);
   else
     val_ptr->set((const char*) typelib->type_names[tmp-1],
-		 (uint) strlen(typelib->type_names[tmp-1]),
+		 typelib->type_lengths[tmp-1],
 		 field_charset);
   return val_ptr;
 }
@@ -5669,13 +5668,14 @@
   res.append("enum(");
 
   bool flag=0;
-  for (const char **pos= typelib->type_names; *pos; pos++)
+  uint *len= typelib->type_lengths;
+  for (const char **pos= typelib->type_names; *pos; pos++, len++)
   {
     uint dummy_errors;
     if (flag)
       res.append(',');
     /* convert to res.charset() == utf8, then quote */
-    enum_item.copy(*pos, strlen(*pos), charset(), res.charset(), &dummy_errors);
+    enum_item.copy(*pos, *len, charset(), res.charset(), &dummy_errors);
     append_unescaped(&res, enum_item.ptr(), enum_item.length());
     flag= 1;
   }
@@ -5760,9 +5760,9 @@
     if (tmp & 1)
     {
       if (val_buffer->length())
-	val_buffer->append(field_separator);
+	val_buffer->append(&field_separator, 1, &my_charset_latin1);
       String str(typelib->type_names[bitnr],
-		 (uint) strlen(typelib->type_names[bitnr]),
+		 typelib->type_lengths[bitnr],
 		 field_charset);
       val_buffer->append(str);
     }
@@ -5782,13 +5782,14 @@
   res.append("set(");
 
   bool flag=0;
-  for (const char **pos= typelib->type_names; *pos; pos++)
+  uint *len= typelib->type_lengths;
+  for (const char **pos= typelib->type_names; *pos; pos++, len++)
   {
     uint dummy_errors;
     if (flag)
       res.append(',');
     /* convert to res.charset() == utf8, then quote */
-    set_item.copy(*pos, strlen(*pos), charset(), res.charset(), &dummy_errors);
+    set_item.copy(*pos, *len, charset(), res.charset(), &dummy_errors);
     append_unescaped(&res, set_item.ptr(), set_item.length());
     flag= 1;
   }

--- 1.198/sql/item_strfunc.cc	2004-11-12 22:47:38 +04:00
+++ 1.199/sql/item_strfunc.cc	2004-12-06 20:33:12 +04:00
@@ -2320,17 +2320,6 @@
   return &tmp_value;
 }
 
-inline int hexchar_to_int(char c)
-{
-  if (c <= '9' && c >= '0')
-    return c-'0';
-  c|=32;
-  if (c <= 'f' && c >= 'a')
-    return c-'a'+10;
-  return -1;
-}
-
-
   /* Convert given hex string to a binary string */
 
 String *Item_func_unhex::val_str(String *str)

--- 1.330/sql/mysql_priv.h	2004-12-02 17:13:58 +04:00
+++ 1.331/sql/mysql_priv.h	2004-12-06 20:33:12 +04:00
@@ -1201,6 +1201,23 @@
 
 
 /*
+  SYNOPSYS
+    hexchar_to_int()
+    convert a hex digit into number
+*/
+
+inline int hexchar_to_int(char c)
+{
+  if (c <= '9' && c >= '0')
+    return c-'0';
+  c|=32;
+  if (c <= 'f' && c >= 'a')
+    return c-'a'+10;
+  return -1;
+}
+
+
+/*
   Some functions that are different in the embedded library and the normal
   server
 */

--- 1.117/sql/table.cc	2004-11-25 15:56:05 +04:00
+++ 1.118/sql/table.cc	2004-12-06 20:33:12 +04:00
@@ -485,6 +485,23 @@
         charset= outparam->table_charset;
       bzero((char*) &comment, sizeof(comment));
     }
+
+    if (interval_nr && charset->mbminlen > 1)
+    {
+      /* Unescape UCS2 intervals from HEX notation */
+      TYPELIB *interval= outparam->intervals + interval_nr - 1;
+      for (uint pos= 0; pos < interval->count; pos++)
+      {
+        char *from, *to;
+        for (from= to= (char*) interval->type_names[pos]; *from; )
+        {
+          *to++= (char) (hexchar_to_int(*from++) << 4) + 
+                         hexchar_to_int(*from++);
+        }
+        interval->type_lengths[pos] /= 2;
+      }
+    }
+    
     *field_ptr=reg_field=
       make_field(record+recpos,
 		 (uint32) field_length,

--- 1.43/sql/unireg.cc	2004-07-29 13:33:31 +05:00
+++ 1.44/sql/unireg.cc	2004-12-06 20:33:12 +04:00
@@ -423,6 +423,28 @@
     if (field->interval)
     {
       uint old_int_count=int_count;
+
+      if (field->charset->mbminlen > 1)
+      {
+        /* Escape UCS2 intervals using HEX notation */
+        for (uint pos= 0; pos < field->interval->count; pos++)
+        {
+          char *dst;
+          uint length= field->interval->type_lengths[pos], hex_length;
+          const char *src= field->interval->type_names[pos];
+          const char *srcend= src + length;
+          hex_length= length * 2;
+          field->interval->type_lengths[pos]= hex_length;
+          field->interval->type_names[pos]= dst= sql_alloc(hex_length + 1);
+          for ( ; src < srcend; src++)
+          {
+            *dst++= _dig_vec_upper[((uchar) *src) >> 4];
+            *dst++= _dig_vec_upper[((uchar) *src) & 15];
+          }
+          *dst= '\0';
+        }
+      }
+
       field->interval_id=get_interval_id(&int_count,create_fields,field);
       if (old_int_count != int_count)
       {

--- 1.17/mysql-test/r/ctype_ucs.result	2004-12-01 19:25:00 +04:00
+++ 1.18/mysql-test/r/ctype_ucs.result	2004-12-06 20:33:12 +04:00
@@ -525,3 +525,59 @@
 SET TIMESTAMP=10000;
 insert into t2 values (@v);
 drop table t2;
+set names latin1;
+create table t1 (a enum('x','y','z') character set ucs2);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` enum('x','y','z') character set ucs2 default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values ('x');
+insert into t1 values ('y');
+insert into t1 values ('z');
+select a, hex(a) from t1 order by a;
+a	hex(a)
+x	0078
+y	0079
+z	007A
+alter table t1 change a a enum('x','y','z','d','e','ä','ö','ü') character set ucs2;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` enum('x','y','z','d','e','ä','ö','ü') character set ucs2 default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values ('D');
+insert into t1 values ('E ');
+insert into t1 values ('Ä');
+insert into t1 values ('Ö');
+insert into t1 values ('Ü');
+select a, hex(a) from t1 order by a;
+a	hex(a)
+x	0078
+y	0079
+z	007A
+d	0064
+e	0065
+ä	00E4
+ö	00F6
+ü	00FC
+drop table t1;
+create table t1 (a set ('x','y','z','ä','ö','ü') character set ucs2);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` set('x','y','z','ä','ö','ü') character set ucs2 default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values ('x');
+insert into t1 values ('y');
+insert into t1 values ('z');
+insert into t1 values ('x,y');
+insert into t1 values ('x,y,z,Ä,Ö,Ü');
+select a, hex(a) from t1 order by a;
+a	hex(a)
+x	0078
+y	0079
+x,y	0078002C0079
+z	007A
+x,y,z,ä,ö,ü	0078002C0079002C007A002C00E4002C00F6002C00FC
+drop table t1;

--- 1.16/mysql-test/t/ctype_ucs.test	2004-12-01 19:25:00 +04:00
+++ 1.17/mysql-test/t/ctype_ucs.test	2004-12-06 20:33:12 +04:00
@@ -343,3 +343,34 @@
 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
 --exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 
 drop table t2;
+
+
+#
+# Check that ucs2 works with ENUM and SET type
+#
+set names latin1;
+create table t1 (a enum('x','y','z') character set ucs2);
+show create table t1;
+insert into t1 values ('x');
+insert into t1 values ('y');
+insert into t1 values ('z');
+select a, hex(a) from t1 order by a;
+alter table t1 change a a enum('x','y','z','d','e','ä','ö','ü') character set ucs2;
+show create table t1;
+insert into t1 values ('D');
+insert into t1 values ('E ');
+insert into t1 values ('Ä');
+insert into t1 values ('Ö');
+insert into t1 values ('Ü');
+select a, hex(a) from t1 order by a;
+drop table t1;
+
+create table t1 (a set ('x','y','z','ä','ö','ü') character set ucs2);
+show create table t1;
+insert into t1 values ('x');
+insert into t1 values ('y');
+insert into t1 values ('z');
+insert into t1 values ('x,y');
+insert into t1 values ('x,y,z,Ä,Ö,Ü');
+select a, hex(a) from t1 order by a;
+drop table t1;

--- 1.4/sql/strfunc.cc	2004-10-26 12:42:13 +05:00
+++ 1.5/sql/strfunc.cc	2004-12-06 20:33:12 +04:00
@@ -53,8 +53,22 @@
     {
       const char *pos= start;
       uint var_len;
+      int mblen= 1;
 
-      for (; pos != end && *pos != field_separator; pos++) ;
+      if (cs && cs->mbminlen > 1)
+      {
+        for ( ; pos < end; pos+= mblen)
+        {
+          my_wc_t wc;
+          if ((mblen= cs->cset->mb_wc(cs, &wc, (const uchar *) pos, 
+                                               (const uchar *) end)) < 1)
+            mblen= 1; // Not to hang on a wrong multibyte sequence
+          if (wc == (my_wc_t) field_separator)
+            break;
+        }
+      }
+      else
+        for (; pos != end && *pos != field_separator; pos++) ;
       var_len= (uint) (pos - start);
       uint find= cs ? find_type2(lib, start, var_len, cs) :
                       find_type(lib, start, var_len, (bool) 0);
@@ -66,9 +80,9 @@
       }
       else
         found|= ((longlong) 1 << (find - 1));
-      if (pos == end)
+      if (pos >= end)
         break;
-      start= pos + 1;
+      start= pos + mblen;
     }
   }
   return found;
Thread
bk commit into 4.1 tree (bar:1.2137)bar6 Dec