Loading mysql-test/r/ctype_ucs.result +56 −0 Original line number Diff line number Diff line Loading @@ -525,3 +525,59 @@ use test; 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; mysql-test/t/ctype_ucs.test +31 −0 Original line number Diff line number Diff line Loading @@ -343,3 +343,34 @@ show binlog events from 79; --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; sql/field.cc +10 −9 Original line number Diff line number Diff line Loading @@ -5529,8 +5529,7 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs) } /* 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) { Loading Loading @@ -5632,7 +5631,7 @@ String *Field_enum::val_str(String *val_buffer __attribute__((unused)), 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; } Loading Loading @@ -5669,13 +5668,14 @@ void Field_enum::sql_type(String &res) const 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; } Loading Loading @@ -5760,9 +5760,9 @@ String *Field_set::val_str(String *val_buffer, 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); } Loading @@ -5782,13 +5782,14 @@ void Field_set::sql_type(String &res) const 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; } Loading sql/item_strfunc.cc +0 −11 Original line number Diff line number Diff line Loading @@ -2320,17 +2320,6 @@ String *Item_func_hex::val_str(String *str) 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) Loading sql/mysql_priv.h +17 −0 Original line number Diff line number Diff line Loading @@ -1200,6 +1200,23 @@ inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr) } /* 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 Loading Loading
mysql-test/r/ctype_ucs.result +56 −0 Original line number Diff line number Diff line Loading @@ -525,3 +525,59 @@ use test; 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;
mysql-test/t/ctype_ucs.test +31 −0 Original line number Diff line number Diff line Loading @@ -343,3 +343,34 @@ show binlog events from 79; --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;
sql/field.cc +10 −9 Original line number Diff line number Diff line Loading @@ -5529,8 +5529,7 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs) } /* 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) { Loading Loading @@ -5632,7 +5631,7 @@ String *Field_enum::val_str(String *val_buffer __attribute__((unused)), 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; } Loading Loading @@ -5669,13 +5668,14 @@ void Field_enum::sql_type(String &res) const 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; } Loading Loading @@ -5760,9 +5760,9 @@ String *Field_set::val_str(String *val_buffer, 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); } Loading @@ -5782,13 +5782,14 @@ void Field_set::sql_type(String &res) const 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; } Loading
sql/item_strfunc.cc +0 −11 Original line number Diff line number Diff line Loading @@ -2320,17 +2320,6 @@ String *Item_func_hex::val_str(String *str) 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) Loading
sql/mysql_priv.h +17 −0 Original line number Diff line number Diff line Loading @@ -1200,6 +1200,23 @@ inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr) } /* 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 Loading