summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
authorbar@mysql.com <>2004-08-11 14:03:24 +0500
committerbar@mysql.com <>2004-08-11 14:03:24 +0500
commit127cf25c017505359bf17d43d1f431a47276619b (patch)
treea6c87b30ad194b5057eebc2ed1a833dea5e911a7 /sql/sql_show.cc
parent902518ae4859d47b6116e05a20f5e4c2313197b5 (diff)
downloadmariadb-git-127cf25c017505359bf17d43d1f431a47276619b.tar.gz
ctype_recoding.result, ctype_recoding.test, sql_show.cc:
Bug#4417: SHOW CREATE TABLE and SHOW COLUMNS now return consistent results when "SET NAMES BINARY", i.e. everything is sent in UTF8: column names, enum values, default values.
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 6d328243a59..57c5f01d0bf 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -651,6 +651,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
TABLE *table;
handler *file;
char tmp[MAX_FIELD_WIDTH];
+ char tmp1[MAX_FIELD_WIDTH];
Item *item;
Protocol *protocol= thd->protocol;
DBUG_ENTER("mysqld_show_fields");
@@ -735,9 +736,24 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
else if (field->unireg_check != Field::NEXT_NUMBER &&
!field->is_null())
{ // Not null by default
+ /*
+ Note: we have to convert the default value into
+ system_charset_info before sending.
+ This is necessary for "SET NAMES binary":
+ If the client character set is binary, we want to
+ send metadata in UTF8 rather than in the column's
+ character set.
+ This conversion also makes "SHOW COLUMNS" and
+ "SHOW CREATE TABLE" output consistent. Without
+ this conversion the default values were displayed
+ differently.
+ */
+ String def(tmp1,sizeof(tmp1), system_charset_info);
type.set(tmp, sizeof(tmp), field->charset());
field->val_str(&type);
- protocol->store(type.ptr(),type.length(),type.charset());
+ def.copy(type.ptr(), type.length(), type.charset(),
+ system_charset_info);
+ protocol->store(def.ptr(), def.length(), def.charset());
}
else if (field->unireg_check == Field::NEXT_NUMBER ||
field->maybe_null())