From 4ee94d21f35ef40a3d950f5970190b7ffe12d8be Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Jul 2003 17:51:42 +0500 Subject: [PATCH] Database name and national characters fixes. --- mysql-test/r/ctype_recoding.result | 14 ++++++++++++++ mysql-test/t/ctype_recoding.test | 11 +++++++++++ sql/sql_parse.cc | 19 +++++++++++++++---- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index 23a90be1306..b89a90cc6ba 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -42,3 +42,17 @@ Field Type Null Key Default Extra SET CHARACTER SET koi8r; DROP TABLE ΤΑΒΜΙΓΑ; SET CHARACTER SET default; +SET CHARACTER SET koi8r; +CREATE DATABASE ΤΕΣΤ; +USE ΤΕΣΤ; +SHOW TABLES; +Tables_in_ΤΕΣΤ +SHOW TABLES IN ΤΕΣΤ; +Tables_in_ΤΕΣΤ +SET CHARACTER SET cp1251; +SHOW TABLES; +Tables_in_ςερς +SHOW TABLES IN ςερς; +Tables_in_ςερς +SET CHARACTER SET koi8r; +DROP DATABASE ΤΕΣΤ; diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index 68526806166..8fa31b1f17b 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -27,3 +27,14 @@ SHOW FIELDS FROM Ρ‚Π°Π±Π»ΠΈΡ†Π°; SET CHARACTER SET koi8r; DROP TABLE ΤΑΒΜΙΓΑ; SET CHARACTER SET default; + +SET CHARACTER SET koi8r; +CREATE DATABASE ΤΕΣΤ; +USE ΤΕΣΤ; +SHOW TABLES; +SHOW TABLES IN ΤΕΣΤ; +SET CHARACTER SET cp1251; +SHOW TABLES; +SHOW TABLES IN ςερς; +SET CHARACTER SET koi8r; +DROP DATABASE ΤΕΣΤ; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 820bf3d73cc..720017f399f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -549,6 +549,7 @@ check_connections(THD *thd) char *end, *user, *passwd, *db; char prepared_scramble[SCRAMBLE41_LENGTH+4]; /* Buffer for scramble&hash */ ACL_USER* cached_user=NULL; /* Initialise to NULL for first stage */ + String convdb; DBUG_PRINT("info",("New connection received on %s", vio_description(net->vio))); @@ -724,7 +725,12 @@ check_connections(THD *thd) db=0; using_password= test(passwd[0]); if (thd->client_capabilities & CLIENT_CONNECT_WITH_DB) + { db=strend(passwd)+1; + convdb.copy(db, strlen(db), + thd->variables.character_set_client, system_charset_info); + db= convdb.c_ptr(); + } /* We can get only old hash at this point */ if (using_password && strlen(passwd) != SCRAMBLE_LENGTH) @@ -1125,10 +1131,15 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd->lex.select_lex.options=0; // We store status here switch (command) { case COM_INIT_DB: - statistic_increment(com_stat[SQLCOM_CHANGE_DB],&LOCK_status); - if (!mysql_change_db(thd,packet)) - mysql_log.write(thd,command,"%s",thd->db); - break; + { + String convname; + statistic_increment(com_stat[SQLCOM_CHANGE_DB],&LOCK_status); + convname.copy(packet, strlen(packet), + thd->variables.character_set_client, system_charset_info); + if (!mysql_change_db(thd,convname.c_ptr())) + mysql_log.write(thd,command,"%s",thd->db); + break; + } #ifndef EMBEDDED_LIBRARY case COM_REGISTER_SLAVE: {