List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:December 24 2008 5:25pm
Subject:bzr commit into mysql-6.0-bugteam branch (Sergey.Glukhov:2811)
Bug#21317
View as plain text  
#At file:///home/gluh/MySQL/mysql-6.0-bug-21317/ based on revid:epotemkin@stripped09-pgt52a3gy35asgsg

 2811 Sergey Glukhov	2008-12-24
      Bug#21317 SHOW CREATE DATABASE does not obey to lower_case_table_names
      preserve lettercase for DB name as it specified in 'show create'
modified:
  mysql-test/r/lowercase_table.result
  mysql-test/t/lowercase_table.test
  sql/mysql_priv.h
  sql/sql_db.cc
  sql/sql_parse.cc
  sql/sql_show.cc
  sql/sql_show.h
  sql/sql_yacc.yy
  sql/table.cc

per-file messages:
  mysql-test/r/lowercase_table.result
    test result
  mysql-test/t/lowercase_table.test
    test case
  sql/mysql_priv.h
    renamed check_db_name() func to check_and_convert_db_name,
    added new parameter 'preserve_lettercase' to this func.
  sql/sql_db.cc
    renamed check_db_name() func to check_and_convert_db_name
  sql/sql_parse.cc
    renamed check_db_name() func to check_and_convert_db_name
  sql/sql_show.cc
    preserve lettercase for DB name as it specified in 'show create'
  sql/sql_show.h
    added new parameter 'orig_dbname' to store_db_create_info func
  sql/sql_yacc.yy
    renamed check_db_name() func to check_and_convert_db_name
  sql/table.cc
    renamed check_db_name() func to check_and_convert_db_name
=== modified file 'mysql-test/r/lowercase_table.result'
--- a/mysql-test/r/lowercase_table.result	2006-11-03 09:08:53 +0000
+++ b/mysql-test/r/lowercase_table.result	2008-12-24 18:26:15 +0000
@@ -108,3 +108,9 @@ ii
 drop table İİ;
 set names latin1;
 End of 5.0 tests
+create database mysql_TEST;
+show create database mysql_TEST;
+Database	Create Database
+mysql_TEST	CREATE DATABASE `mysql_TEST` /*!40100 DEFAULT CHARACTER SET latin1 */
+drop database mysql_TEST;
+End of 6.0 tests

=== modified file 'mysql-test/t/lowercase_table.test'
--- a/mysql-test/t/lowercase_table.test	2006-10-30 10:40:15 +0000
+++ b/mysql-test/t/lowercase_table.test	2008-12-24 18:26:15 +0000
@@ -105,3 +105,12 @@ drop table İİ;
 set names latin1;
 
 --echo End of 5.0 tests
+
+#
+# Bug#21317: SHOW CREATE DATABASE does not obey to lower_case_table_names
+#
+create database mysql_TEST;
+show create database mysql_TEST;
+drop database mysql_TEST;
+
+--echo End of 6.0 tests

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2008-12-09 09:27:28 +0000
+++ b/sql/mysql_priv.h	2008-12-24 18:26:15 +0000
@@ -2315,7 +2315,7 @@ int create_frm(THD *thd, const char *nam
 	       HA_CREATE_INFO *create_info, uint keys, KEY *key_info);
 void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form);
 int rename_file_ext(const char * from,const char * to,const char * ext);
-bool check_db_name(LEX_STRING *db);
+bool check_and_convert_db_name(LEX_STRING *db, bool preserve_lettercase);
 bool check_column_name(const char *name);
 bool check_table_name(const char *name, uint length);
 char *get_field(MEM_ROOT *mem, Field *field);

=== modified file 'sql/sql_db.cc'
--- a/sql/sql_db.cc	2008-11-14 17:41:51 +0000
+++ b/sql/sql_db.cc	2008-12-24 18:26:15 +0000
@@ -1588,7 +1588,7 @@ bool mysql_change_db(THD *thd, const LEX
     in this case to be sure.
   */
 
-  if (check_db_name(&new_db_file_name))
+  if (check_and_convert_db_name(&new_db_file_name, FALSE))
   {
     my_error(ER_WRONG_DB_NAME, MYF(0), new_db_file_name.str);
     my_free(new_db_file_name.str, MYF(0));

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2008-11-17 09:57:51 +0000
+++ b/sql/sql_parse.cc	2008-12-24 18:26:15 +0000

@@ -1549,7 +1549,7 @@ int prepare_schema_table(THD *thd, LEX *
       schema_select_lex->table_list.first= NULL;
       db.length= strlen(db.str);
 
-      if (check_db_name(&db))
+      if (check_and_convert_db_name(&db, FALSE))
       {
         my_error(ER_WRONG_DB_NAME, MYF(0), db.str);
         DBUG_RETURN(1);
@@ -3541,7 +3541,7 @@ ddl_blocker_err:
     HA_CREATE_INFO create_info(lex->create_info);
     char *alias;
     if (!(alias=thd->strmake(lex->name.str, lex->name.length)) ||
-        check_db_name(&lex->name))
+        check_and_convert_db_name(&lex->name, FALSE))
     {
       my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str);
       break;
@@ -3574,7 +3574,7 @@ ddl_blocker_err:
   }
   case SQLCOM_DROP_DB:
   {
-    if (check_db_name(&lex->name))
+    if (check_and_convert_db_name(&lex->name, FALSE))
     {
       my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str);
       break;
@@ -3623,7 +3623,7 @@ ddl_blocker_err:
       break;
     }
 #endif
-    if (check_db_name(db))
+    if (check_and_convert_db_name(db, FALSE))
     {
       my_error(ER_WRONG_DB_NAME, MYF(0), db->str);
       break;
@@ -3655,7 +3655,7 @@ ddl_blocker_err:
   {
     LEX_STRING *db= &lex->name;
     HA_CREATE_INFO create_info(lex->create_info);
-    if (check_db_name(db))
+    if (check_and_convert_db_name(db, FALSE))
     {
       my_error(ER_WRONG_DB_NAME, MYF(0), db->str);
       break;
@@ -3694,7 +3694,7 @@ ddl_blocker_err:
   {
     DBUG_EXECUTE_IF("4x_server_emul",
                     my_error(ER_UNKNOWN_ERROR, MYF(0)); goto error;);
-    if (check_db_name(&lex->name))
+    if (check_and_convert_db_name(&lex->name, TRUE))
     {
       my_error(ER_WRONG_DB_NAME, MYF(0), lex->name.str);
       break;
@@ -4071,7 +4071,7 @@ ddl_blocker_err:
       Verify that the database name is allowed, optionally
       lowercase it.
     */
-    if (check_db_name(&lex->sphead->m_db))
+    if (check_and_convert_db_name(&lex->sphead->m_db, FALSE))
     {
       my_error(ER_WRONG_DB_NAME, MYF(0), lex->sphead->m_db.str);
       goto create_sp_error;
@@ -5988,7 +5988,7 @@ TABLE_LIST *st_select_lex::add_table_to_
   }
 
   if (table->is_derived_table() == FALSE && table->db.str &&
-      check_db_name(&table->db))
+      check_and_convert_db_name(&table->db, FALSE))
   {
     my_error(ER_WRONG_DB_NAME, MYF(0), table->db.str);
     DBUG_RETURN(0);

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2008-12-10 15:59:12 +0000
+++ b/sql/sql_show.cc	2008-12-24 18:26:15 +0000
@@ -604,7 +604,7 @@ mysqld_show_create(THD *thd, TABLE_LIST 
 bool mysqld_show_create_db(THD *thd, char *dbname,
                            HA_CREATE_INFO *create_info)
 {
-  char buff[2048];
+  char buff[2048], orig_dbname[NAME_LEN];
   String buffer(buff, sizeof(buff), system_charset_info);
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
   Security_context *sctx= thd->security_ctx;
@@ -613,6 +613,10 @@ bool mysqld_show_create_db(THD *thd, cha
   Protocol *protocol=thd->protocol;
   DBUG_ENTER("mysql_show_create_db");
 
+  strcpy(orig_dbname, dbname);
+  if (lower_case_table_names && dbname != any_db)
+    my_casedn_str(files_charset_info, dbname);
+
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
   if (test_all_bits(sctx->master_access, DB_ACLS))
     db_access=DB_ACLS;
@@ -629,7 +633,7 @@ bool mysqld_show_create_db(THD *thd, cha
   }
 #endif
 
-  if (store_db_create_info(thd, dbname, &buffer, create_info))
+  if (store_db_create_info(thd, dbname, &buffer, create_info, orig_dbname))
   {
     /* 
       This assumes that the only reason for which store_db_create_info()
@@ -648,7 +652,7 @@ bool mysqld_show_create_db(THD *thd, cha
     DBUG_RETURN(TRUE);
 
   protocol->prepare_for_resend();
-  protocol->store(dbname, strlen(dbname), system_charset_info);
+  protocol->store(orig_dbname, strlen(orig_dbname), system_charset_info);
   protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
 
   if (protocol->write())
@@ -1427,7 +1431,7 @@ int store_create_info(THD *thd, TABLE_LI
 */
 
 bool store_db_create_info(THD *thd, const char *dbname, String *buffer,
-                          HA_CREATE_INFO *create_info)
+                          HA_CREATE_INFO *create_info, const char* orig_dbname)
 {
   HA_CREATE_INFO create;
   uint create_options = create_info ? create_info->options : 0;
@@ -1455,7 +1459,7 @@ bool store_db_create_info(THD *thd, cons
   if (create_options & HA_LEX_CREATE_IF_NOT_EXISTS)
     buffer->append(STRING_WITH_LEN("/*!32312 IF NOT EXISTS*/ "));
 
-  append_identifier(thd, buffer, dbname, strlen(dbname));
+  append_identifier(thd, buffer, orig_dbname, strlen(orig_dbname));
 
   if (create.default_table_charset)
   {

=== modified file 'sql/sql_show.h'
--- a/sql/sql_show.h	2008-10-08 11:46:49 +0000
+++ b/sql/sql_show.h	2008-12-24 18:26:15 +0000
@@ -35,7 +35,7 @@ find_files_result find_files(THD *thd, L
 int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
                       HA_CREATE_INFO  *create_info_arg, bool show_database);
 bool store_db_create_info(THD *thd, const char *dbname, String *buffer,
-                          HA_CREATE_INFO *create_info);
+                          HA_CREATE_INFO *create_info, const char *orig_dbname);
 int view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
 
 int copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table);

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2008-12-12 17:36:43 +0000
+++ b/sql/sql_yacc.yy	2008-12-24 18:26:15 +0000
@@ -2177,7 +2177,7 @@ clear_privileges:
 sp_name:
           ident '.' ident
           {
-            if (!$1.str || check_db_name(&$1))
+            if (!$1.str || check_and_convert_db_name(&$1, FALSE))
             {
               my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
               MYSQL_YYABORT;
@@ -6243,7 +6243,7 @@ alter_list_item:
               MYSQL_YYABORT;
             }
             if (check_table_name($3->table.str,$3->table.length) ||
-                $3->db.str && check_db_name(&$3->db))
+                $3->db.str && check_and_convert_db_name(&$3->db, FALSE))
             {
               my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str);
               MYSQL_YYABORT;

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2008-12-08 13:44:20 +0000
+++ b/sql/table.cc	2008-12-24 18:26:15 +0000
@@ -2824,16 +2824,18 @@ uint calculate_key_len(TABLE *table, uin
   SYNPOSIS
     check_db_name()
     org_name		Name of database and length
+    preserve_lettercase Preserve lettercase if true
 
   NOTES
-    If lower_case_table_names is set then database is converted to lower case
+    If lower_case_table_names is true and preserve_lettercase is false then
+    database is converted to lower case
 
   RETURN
     0	ok
     1   error
 */
 
-bool check_db_name(LEX_STRING *org_name)
+bool check_and_convert_db_name(LEX_STRING *org_name, bool preserve_lettercase)
 {
   char *name= org_name->str;
   uint name_length= org_name->length;
@@ -2841,7 +2843,7 @@ bool check_db_name(LEX_STRING *org_name)
   if (!name_length || name_length > NAME_LEN || name[name_length - 1] == ' ')
     return 1;
 
-  if (lower_case_table_names && name != any_db)
+  if (!preserve_lettercase && lower_case_table_names && name != any_db)
     my_casedn_str(files_charset_info, name);
 
   return check_identifier_name(org_name);

Thread
bzr commit into mysql-6.0-bugteam branch (Sergey.Glukhov:2811)Bug#21317Sergey Glukhov24 Dec
  • Re: bzr commit into mysql-6.0-bugteam branch (Sergey.Glukhov:2811)Bug#21317Sergei Golubchik8 Jan