From 5be2b8b11a731a31960fe94af67aaf5173115390 Mon Sep 17 00:00:00 2001 From: "bar@bar.intranet.mysql.r18.ru" <> Date: Fri, 19 Dec 2003 19:12:11 +0400 Subject: [PATCH] Fix for Bug#2151: "USE db" affected the character set of further CREATE DATABASEs, which should have not happened. --- BitKeeper/etc/logging_ok | 1 + mysql-test/r/ctype_create.result | 20 ++++++++++++++++ mysql-test/t/ctype_create.test | 39 ++++++++++++++++++++++++++++++++ mysys/charset2html.c | 2 +- sql/sql_db.cc | 8 +++---- 5 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 mysql-test/r/ctype_create.result create mode 100644 mysql-test/t/ctype_create.test 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("