From 05c0c4ff2672646954e1bd54640ea07c2ebe1d36 Mon Sep 17 00:00:00 2001 From: "ram@gw.mysql.r18.ru" <> Date: Mon, 15 Dec 2003 21:01:38 +0400 Subject: [PATCH] part one of the fix for the bug #2077: accented characters in enum/defaul values are reported incorrectly --- mysql-test/r/type_enum.result | 10 ++++++++++ mysql-test/t/type_enum.test | 10 ++++++++++ sql/sql_show.cc | 8 ++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/type_enum.result b/mysql-test/r/type_enum.result index 42ee54ce105..1903037480a 100644 --- a/mysql-test/r/type_enum.result +++ b/mysql-test/r/type_enum.result @@ -1636,3 +1636,13 @@ t1 CREATE TABLE `t1` ( `a` enum('','a','b') NOT NULL default 'b' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +create table t1 (a enum(0xE4, '1', '2') not null default 0xE4); +show columns from t1; +Field Type Null Key Default Extra +a enum('ä','1','2') ä +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('ä','1','2') NOT NULL default '?' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/t/type_enum.test b/mysql-test/t/type_enum.test index 49ba73acaa8..bcebb1a5b27 100644 --- a/mysql-test/t/type_enum.test +++ b/mysql-test/t/type_enum.test @@ -24,3 +24,13 @@ drop table t1; create table t1 (a enum (' ','a','b ') not null default 'b '); show create table t1; drop table t1; + +# +# Bug #2077 +# + +create table t1 (a enum(0xE4, '1', '2') not null default 0xE4); +show columns from t1; +# should be fixed ASAP +show create table t1; +drop table t1; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2ef7262f45c..855b5d1e97e 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -688,14 +688,14 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, { byte *pos; uint flags=field->flags; - String type(tmp,sizeof(tmp), system_charset_info); + String type(tmp,sizeof(tmp), field->charset()); uint col_access; bool null_default_value=0; protocol->prepare_for_resend(); protocol->store(field->field_name, system_charset_info); field->sql_type(type); - protocol->store(type.ptr(), type.length(), system_charset_info); + protocol->store(type.ptr(), type.length(), type.charset()); if (verbose) protocol->store(field->has_charset() ? field->charset()->name : "NULL", system_charset_info); @@ -713,7 +713,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, null_default_value=1; if (!null_default_value && !field->is_null()) { // Not null by default - type.set(tmp,sizeof(tmp),system_charset_info); + type.set(tmp, sizeof(tmp), field->charset()); field->val_str(&type,&type); protocol->store(type.ptr(),type.length(),type.charset()); } @@ -1114,7 +1114,7 @@ store_create_info(THD *thd, TABLE *table, String *packet) packet->append(" default ", 9); if (!field->is_null()) { // Not null by default - type.set(tmp,sizeof(tmp),&my_charset_bin); + type.set(tmp, sizeof(tmp), field->charset()); field->val_str(&type,&type); if (type.length()) append_unescaped(packet, type.ptr(), type.length());