Commit 0137c812 authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

SHOW CREATE TABLE didn't display field names in the proper charset

parent 7549a76c
SET NAMES koi8r;
DROP TABLE IF EXISTS ;
CREATE TABLE
(
CHAR(32) CHARACTER SET koi8r NOT NULL
);
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 cp1251;
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 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 ;
SET NAMES koi8r;
--disable_warnings
DROP TABLE IF EXISTS ;
--enable_warnings
CREATE TABLE
(
CHAR(32) CHARACTER SET koi8r NOT NULL
);
SHOW TABLES;
SHOW CREATE TABLE ;
SHOW FIELDS FROM ;
SET NAMES cp1251;
SHOW TABLES;
SHOW CREATE TABLE ;
SHOW FIELDS FROM ;
SET NAMES utf8;
SHOW TABLES;
SHOW CREATE TABLE таблица;
SHOW FIELDS FROM таблица;
SET NAMES koi8r;
DROP TABLE ;
...@@ -341,6 +341,8 @@ static int add_collation(CHARSET_INFO *cs) ...@@ -341,6 +341,8 @@ static int add_collation(CHARSET_INFO *cs)
all_charsets[cs->number]->state |= cs->state; all_charsets[cs->number]->state |= cs->state;
} }
cs->number= 0; cs->number= 0;
cs->primary_number= 0;
cs->binary_number= 0;
cs->name= NULL; cs->name= NULL;
cs->state= 0; cs->state= 0;
cs->sort_order= NULL; cs->sort_order= NULL;
......
...@@ -1014,12 +1014,12 @@ append_identifier(THD *thd, String *packet, const char *name) ...@@ -1014,12 +1014,12 @@ append_identifier(THD *thd, String *packet, const char *name)
if (thd->options & OPTION_QUOTE_SHOW_CREATE) if (thd->options & OPTION_QUOTE_SHOW_CREATE)
{ {
packet->append(&qtype, 1); packet->append(&qtype, 1);
packet->append(name); packet->append(name, 0, system_charset_info);
packet->append(&qtype, 1); packet->append(&qtype, 1);
} }
else else
{ {
packet->append(name); packet->append(name, 0, system_charset_info);
} }
} }
......
...@@ -338,6 +338,34 @@ bool String::append(const char *s,uint32 arg_length) ...@@ -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 #ifdef TO_BE_REMOVED
bool String::append(FILE* file, uint32 arg_length, myf my_flags) bool String::append(FILE* file, uint32 arg_length, myf my_flags)
{ {
......
...@@ -181,6 +181,7 @@ class String ...@@ -181,6 +181,7 @@ class String
CHARSET_INFO *csto); CHARSET_INFO *csto);
bool append(const String &s); bool append(const String &s);
bool append(const char *s,uint32 arg_length=0); 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); bool append(IO_CACHE* file, uint32 arg_length);
int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1 int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
int strstr_case(const String &s,uint32 offset=0); int strstr_case(const String &s,uint32 offset=0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment