List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:May 12 2010 10:16am
Subject:bzr commit into mysql-next-mr-bugfixing branch (Sergey.Glukhov:3168)
Bug#21317
View as plain text  
#At file:///home/gluh/MySQL/mysql-next-mr-opt-backporting/ based on revid:gshchepa@stripped00511204839-3kpezexmbdkenm6w

 3168 Sergey Glukhov	2010-05-12
      Bug#21317 SHOW CREATE DATABASE does not obey to lower_case_table_names
      preserve lettercase for DB name as it specified in 'show create'
      (backport to next-mr)
     @ mysql-test/r/lowercase_table.result
        test case
     @ 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_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:
      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_yacc.yy
      sql/table.cc
=== 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	2010-05-12 10:16:43 +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	2010-05-12 10:16:43 +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	2010-05-07 17:44:52 +0000
+++ b/sql/mysql_priv.h	2010-05-12 10:16:43 +0000
@@ -2369,7 +2369,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	2010-03-22 10:36:23 +0000
+++ b/sql/sql_db.cc	2010-05-12 10:16:43 +0000
@@ -1634,7 +1634,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	2010-05-07 12:17:07 +0000
+++ b/sql/sql_parse.cc	2010-05-12 10:16:43 +0000
@@ -1520,7 +1520,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);
@@ -3479,7 +3479,7 @@ end_with_restore_list:
     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;
@@ -3514,7 +3514,7 @@ end_with_restore_list:
   }
   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;
@@ -3559,7 +3559,7 @@ end_with_restore_list:
       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;
@@ -3588,7 +3588,7 @@ end_with_restore_list:
   {
     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;
@@ -3624,7 +3624,7 @@ end_with_restore_list:
   {
     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;
@@ -4012,7 +4012,7 @@ end_with_restore_list:
       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;
@@ -5991,7 +5991,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	2010-03-25 11:14:23 +0000
+++ b/sql/sql_show.cc	2010-05-12 10:16:43 +0000
@@ -724,7 +724,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;
@@ -735,6 +735,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;
@@ -774,12 +778,12 @@ 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);
   buffer.length(0);
   buffer.append(STRING_WITH_LEN("CREATE DATABASE "));
   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_yacc.yy'
--- a/sql/sql_yacc.yy	2010-05-07 12:17:07 +0000
+++ b/sql/sql_yacc.yy	2010-05-12 10:16:43 +0000
@@ -2369,7 +2369,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;
@@ -6664,7 +6664,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;
@@ -10122,7 +10122,7 @@ drop:
             THD *thd= YYTHD;
             LEX *lex= thd->lex;
             sp_name *spname;
-            if ($4.str && check_db_name(&$4))
+            if ($4.str && check_and_convert_db_name(&$4, FALSE))
             {
                my_error(ER_WRONG_DB_NAME, MYF(0), $4.str);
                MYSQL_YYABORT;

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2010-05-02 19:14:50 +0000
+++ b/sql/table.cc	2010-05-12 10:16:43 +0000
@@ -2704,16 +2704,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;
@@ -2721,7 +2723,7 @@ bool check_db_name(LEX_STRING *org_name)
   if (!name_length || name_length > NAME_LEN)
     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);
 
 #if defined(USE_MB) && defined(USE_MB_IDENT)

Attachment: [text/bzr-bundle] bzr/sergey.glukhov@sun.com-20100512101643-72pus5rvzo85iku2.bundle
Thread
bzr commit into mysql-next-mr-bugfixing branch (Sergey.Glukhov:3168)Bug#21317Sergey Glukhov12 May