mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
SHOW CREATE TABLE didn't display field names in the proper charset
mysys/charset.c: Clear all fields at the end of previous charset
This commit is contained in:
43
mysql-test/r/ctype_recoding.result
Normal file
43
mysql-test/r/ctype_recoding.result
Normal file
@ -0,0 +1,43 @@
|
||||
SET NAMES koi8r;
|
||||
DROP TABLE IF EXISTS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
CREATE TABLE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
(
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> CHAR(32) CHARACTER SET koi8r NOT NULL
|
||||
);
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SHOW CREATE TABLE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
Table Create Table
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CREATE TABLE `<60><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>` (
|
||||
`<60><><EFBFBD><EFBFBD>` char(32) character set koi8r NOT NULL default ''
|
||||
) TYPE=MyISAM CHARSET=latin1
|
||||
SHOW FIELDS FROM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
Field Type Collation Null Key Default Extra
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> char(32) character set koi8r koi8r
|
||||
SET NAMES cp1251;
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SHOW CREATE TABLE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
Table Create Table
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CREATE TABLE `<60><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>` (
|
||||
`<60><><EFBFBD><EFBFBD>` char(32) character set koi8r NOT NULL default ''
|
||||
) TYPE=MyISAM CHARSET=latin1
|
||||
SHOW FIELDS FROM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
Field Type Collation Null Key Default Extra
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> char(32) character set koi8r koi8r
|
||||
SET NAMES utf8;
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
таблица
|
||||
SHOW CREATE TABLE таблица;
|
||||
Table Create Table
|
||||
таблица CREATE TABLE `таблица` (
|
||||
`поле` char(32) character set koi8r NOT NULL default ''
|
||||
) TYPE=MyISAM CHARSET=latin1
|
||||
SHOW FIELDS FROM таблица;
|
||||
Field Type Collation Null Key Default Extra
|
||||
поле char(32) character set koi8r koi8r
|
||||
SET NAMES koi8r;
|
||||
DROP TABLE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
28
mysql-test/t/ctype_recoding.test
Normal file
28
mysql-test/t/ctype_recoding.test
Normal file
@ -0,0 +1,28 @@
|
||||
SET NAMES koi8r;
|
||||
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
(
|
||||
<20><><EFBFBD><EFBFBD> CHAR(32) CHARACTER SET koi8r NOT NULL
|
||||
);
|
||||
|
||||
SHOW TABLES;
|
||||
SHOW CREATE TABLE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
SHOW FIELDS FROM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
|
||||
SET NAMES cp1251;
|
||||
SHOW TABLES;
|
||||
SHOW CREATE TABLE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
SHOW FIELDS FROM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
||||
|
||||
|
||||
SET NAMES utf8;
|
||||
SHOW TABLES;
|
||||
SHOW CREATE TABLE таблица;
|
||||
SHOW FIELDS FROM таблица;
|
||||
|
||||
SET NAMES koi8r;
|
||||
DROP TABLE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
@ -341,6 +341,8 @@ static int add_collation(CHARSET_INFO *cs)
|
||||
all_charsets[cs->number]->state |= cs->state;
|
||||
}
|
||||
cs->number= 0;
|
||||
cs->primary_number= 0;
|
||||
cs->binary_number= 0;
|
||||
cs->name= NULL;
|
||||
cs->state= 0;
|
||||
cs->sort_order= NULL;
|
||||
|
@ -1014,12 +1014,12 @@ append_identifier(THD *thd, String *packet, const char *name)
|
||||
if (thd->options & OPTION_QUOTE_SHOW_CREATE)
|
||||
{
|
||||
packet->append(&qtype, 1);
|
||||
packet->append(name);
|
||||
packet->append(name, 0, system_charset_info);
|
||||
packet->append(&qtype, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet->append(name);
|
||||
packet->append(name, 0, system_charset_info);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,6 +338,34 @@ bool String::append(const char *s,uint32 arg_length)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Append a string in the given charset to the string
|
||||
with character set recoding
|
||||
*/
|
||||
|
||||
|
||||
bool String::append(const char *s,uint32 arg_length, CHARSET_INFO *cs)
|
||||
{
|
||||
if (!arg_length) // Default argument
|
||||
if (!(arg_length= (uint32) strlen(s)))
|
||||
return FALSE;
|
||||
if (str_charset->mbmaxlen > 1)
|
||||
{
|
||||
uint32 add_length=arg_length * str_charset->mbmaxlen;
|
||||
if (realloc(str_length+ add_length))
|
||||
return TRUE;
|
||||
str_length+= copy_and_convert(Ptr+str_length, add_length, str_charset,
|
||||
s, arg_length, cs);
|
||||
return FALSE;
|
||||
}
|
||||
if (realloc(str_length+arg_length))
|
||||
return TRUE;
|
||||
memcpy(Ptr+str_length,s,arg_length);
|
||||
str_length+=arg_length;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
#ifdef TO_BE_REMOVED
|
||||
bool String::append(FILE* file, uint32 arg_length, myf my_flags)
|
||||
{
|
||||
|
@ -181,6 +181,7 @@ public:
|
||||
CHARSET_INFO *csto);
|
||||
bool append(const String &s);
|
||||
bool append(const char *s,uint32 arg_length=0);
|
||||
bool append(const char *s,uint32 arg_length, CHARSET_INFO *cs);
|
||||
bool append(IO_CACHE* file, uint32 arg_length);
|
||||
int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
|
||||
int strstr_case(const String &s,uint32 offset=0);
|
||||
|
Reference in New Issue
Block a user