summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc41
1 files changed, 27 insertions, 14 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 660b8e7e572..16934e33798 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -719,8 +719,8 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
protocol->store(field->field_name, system_charset_info);
field->sql_type(type);
protocol->store(type.ptr(), type.length(), system_charset_info);
- protocol->store(field->charset()->name, system_charset_info);
-
+ protocol->store(field->has_charset() ? field->charset()->name : "NULL",
+ system_charset_info);
pos=(byte*) ((flags & NOT_NULL_FLAG) &&
field->type() != FIELD_TYPE_TIMESTAMP ?
"" : "YES");
@@ -1073,23 +1073,36 @@ store_create_info(THD *thd, TABLE *table, String *packet)
field->sql_type(type);
packet->append(type.ptr(),type.length());
- bool has_default = (field->type() != FIELD_TYPE_BLOB &&
- field->type() != FIELD_TYPE_TIMESTAMP &&
- field->unireg_check != Field::NEXT_NUMBER);
-
- /*
- For string types dump collation name only if
- collation is not primary for the given charset
- */
- if (!(field->charset()->state & MY_CS_PRIMARY) &&
- !limited_mysql_mode && !foreign_db_mode)
+ if (field->has_charset())
{
- packet->append(" collate ", 9);
- packet->append(field->charset()->name);
+ if (field->charset() == &my_charset_bin)
+ packet->append(" binary");
+ else if (!limited_mysql_mode && !foreign_db_mode)
+ {
+ if (field->charset() != table->table_charset)
+ {
+ packet->append(" character set ");
+ packet->append(field->charset()->csname);
+ }
+ /*
+ For string types dump collation name only if
+ collation is not primary for the given charset
+ */
+ if (!(field->charset()->state & MY_CS_PRIMARY))
+ {
+ packet->append(" collate ", 9);
+ packet->append(field->charset()->name);
+ }
+ }
}
+
if (flags & NOT_NULL_FLAG)
packet->append(" NOT NULL", 9);
+ bool has_default = (field->type() != FIELD_TYPE_BLOB &&
+ field->type() != FIELD_TYPE_TIMESTAMP &&
+ field->unireg_check != Field::NEXT_NUMBER);
+
if (has_default)
{
packet->append(" default ", 9);