mirror of
https://github.com/MariaDB/server.git
synced 2025-07-05 12:42:17 +03:00
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. sql/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. mysql-test/t/ctype_recoding.test: 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. mysql-test/r/ctype_recoding.result: 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.
This commit is contained in:
@ -136,6 +136,30 @@ SET character_set_connection=binary;
|
||||
SELECT 'тест' as s;
|
||||
s
|
||||
тест
|
||||
SET NAMES latin1;
|
||||
CREATE TABLE t1 (`<60>` CHAR(128) DEFAULT '<27>', `<60>1` ENUM('<27>1','<27>2') DEFAULT '<27>2');
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`<60>` char(128) default '<27>',
|
||||
`<60>1` enum('<27>1','<27>2') default '<27>2'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
SHOW COLUMNS FROM t1;
|
||||
Field Type Null Key Default Extra
|
||||
<EFBFBD> char(128) YES <09>
|
||||
<EFBFBD>1 enum('<27>1','<27>2') YES <09>2
|
||||
SET NAMES binary;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`ä` char(128) default 'ä',
|
||||
`ä1` enum('ä1','ä2') default 'ä2'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
SHOW COLUMNS FROM t1;
|
||||
Field Type Null Key Default Extra
|
||||
ä char(128) YES ä
|
||||
ä1 enum('ä1','ä2') YES ä2
|
||||
DROP TABLE t1;
|
||||
SET NAMES binary;
|
||||
CREATE TABLE `good<6F><64><EFBFBD><EFBFBD><EFBFBD>` (a int);
|
||||
ERROR HY000: Invalid utf8 character string: '<27><><EFBFBD><EFBFBD><EFBFBD>'
|
||||
|
@ -98,6 +98,20 @@ SET NAMES utf8;
|
||||
SET character_set_connection=binary;
|
||||
SELECT 'тест' as s;
|
||||
|
||||
# Bug#4417, another aspect:
|
||||
# Check that both "SHOW CREATE TABLE" and "SHOW COLUMNS"
|
||||
# return column names and default values in UTF8 after "SET NAMES BINARY"
|
||||
|
||||
SET NAMES latin1;
|
||||
CREATE TABLE t1 (`<60>` CHAR(128) DEFAULT '<27>', `<60>1` ENUM('<27>1','<27>2') DEFAULT '<27>2');
|
||||
SHOW CREATE TABLE t1;
|
||||
SHOW COLUMNS FROM t1;
|
||||
SET NAMES binary;
|
||||
SHOW CREATE TABLE t1;
|
||||
SHOW COLUMNS FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
#
|
||||
# Test that we allow only well-formed UTF8 identitiers
|
||||
#
|
||||
|
@ -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())
|
||||
|
Reference in New Issue
Block a user