diff options
-rw-r--r-- | BitKeeper/etc/logging_ok | 1 | ||||
-rw-r--r-- | mysql-test/r/ctype_create.result | 20 | ||||
-rw-r--r-- | mysql-test/t/ctype_create.test | 39 | ||||
-rw-r--r-- | mysys/charset2html.c | 2 | ||||
-rw-r--r-- | sql/sql_db.cc | 8 |
5 files changed, 65 insertions, 5 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 57b624db888..db4ad62f23b 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -12,6 +12,7 @@ antony@ltantony.rdg.cyberkinetica.homeunix.net arjen@co3064164-a.bitbike.com arjen@fred.bitbike.com arjen@george.bitbike.com +bar@bar.intranet.mysql.r18.ru bar@bar.mysql.r18.ru bar@bar.udmsearch.izhnet.ru bar@gw.udmsearch.izhnet.ru diff --git a/mysql-test/r/ctype_create.result b/mysql-test/r/ctype_create.result new file mode 100644 index 00000000000..b9146b5818f --- /dev/null +++ b/mysql-test/r/ctype_create.result @@ -0,0 +1,20 @@ +SET @@character_set_server=latin5; +CREATE DATABASE db1 DEFAULT CHARACTER SET cp1251; +USE db1; +CREATE DATABASE db2; +SHOW CREATE DATABASE db1; +Database Create Database +db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET cp1251 */ +SHOW CREATE DATABASE db2; +Database Create Database +db2 CREATE DATABASE `db2` /*!40100 DEFAULT CHARACTER SET latin5 */ +DROP DATABASE db2; +USE db1; +CREATE TABLE t1 (a char(10)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=cp1251 +DROP TABLE t1; +DROP DATABASE db1; diff --git a/mysql-test/t/ctype_create.test b/mysql-test/t/ctype_create.test new file mode 100644 index 00000000000..a4858898535 --- /dev/null +++ b/mysql-test/t/ctype_create.test @@ -0,0 +1,39 @@ +# +# Test for various CREATE statements and character sets +# + + +# Check that the database charset is taken from server charset by default: +# - Change local character_set_server variable to latin5. +# - Create database with and without CHARACTER SET specification. +# At the same time check fix for the +# Bug#2151: +# "USE db" with non-default character set should never affect +# further CREATE DATABASEs. + + +SET @@character_set_server=latin5; +CREATE DATABASE db1 DEFAULT CHARACTER SET cp1251; +USE db1; +CREATE DATABASE db2; + +# +# This should be cp1251 +# +SHOW CREATE DATABASE db1; + +# +# This should take the default latin5 value from server level. +# +SHOW CREATE DATABASE db2; +DROP DATABASE db2; + +# +# Check that table value uses database level by default +# +USE db1; +CREATE TABLE t1 (a char(10)); +SHOW CREATE TABLE t1; + +DROP TABLE t1; +DROP DATABASE db1; diff --git a/mysys/charset2html.c b/mysys/charset2html.c index c6112bfeb9e..64021689bea 100644 --- a/mysys/charset2html.c +++ b/mysys/charset2html.c @@ -81,7 +81,7 @@ static void print_cs(CHARSET_INFO *cs) printf("<TR bgcolor=#%s>",clr ? "DDDDDD" : "EEEE99"); printf("<TD>%02X",ch[i].cod); printf("<TD>%04X",ch[i].uni); - printf("<TD>%d",ch[i].srt); + printf("<TD>%02X",ch[i].srt); printf("<TD>%s%s%s%s%s%s%s%s", ch[i].ctp & _U ? "U" : "", diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 1f652524ed3..70b1d1d0d3a 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -62,7 +62,7 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) ulong length; CHARSET_INFO *cs= (create && create->default_table_charset) ? create->default_table_charset : - thd->variables.collation_database; + thd->variables.collation_server; length= my_sprintf(buf,(buf, "default-character-set=%s\ndefault-collation=%s\n", cs->csname,cs->name)); @@ -101,7 +101,7 @@ static bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) uint nbytes; bzero((char*) create,sizeof(*create)); - create->default_table_charset= global_system_variables.collation_database; + create->default_table_charset= thd->variables.collation_server; if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) >= 0) { IO_CACHE cache; @@ -290,7 +290,7 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) { thd->db_charset= (create_info && create_info->default_table_charset) ? create_info->default_table_charset : - global_system_variables.collation_database; + thd->variables.collation_server; thd->variables.collation_database= thd->db_charset; } @@ -665,7 +665,7 @@ bool mysql_change_db(THD *thd, const char *name) load_db_opt(thd, path, &create); thd->db_charset= create.default_table_charset ? create.default_table_charset : - global_system_variables.collation_database; + thd->variables.collation_server; thd->variables.collation_database= thd->db_charset; DBUG_RETURN(0); } |