List:Internals« Previous MessageNext Message »
From:Lu Jingdong Date:October 30 2007 10:24am
Subject:Patch for Bug #26703
View as plain text  
This patch for http://bugs.mysql.com/bug.php?id=26703
bug #26703 DROP DATABASE fails if database contains a #mysql50# table 
with backticks.

--- sql_table.cc.orig   2007-10-30 16:49:58.000000000 +0800
+++ sql_table.cc        2007-10-30 16:52:22.076690056 +0800
@@ -85,7 +85,8 @@
                     system_charset_info,  to, to_length, &errors);
     if (errors) // Old 5.0 name
     {
-      res= (strxnmov(to, to_length, MYSQL50_TABLE_NAME_PREFIX,  from, 
NullS) -
+      res= (strxnmov(to, to_length+MYSQL50_TABLE_NAME_PREFIX_LENGTH,
+                     MYSQL50_TABLE_NAME_PREFIX,  from, NullS) -
             to);
       sql_print_error("Invalid (old?) table or database name '%s'", from);
       /*

--- sql_db.cc.orig      2007-10-30 16:50:20.000000000 +0800
+++ sql_db.cc   2007-10-30 16:53:29.000000000 +0800
@@ -1090,7 +1090,8 @@
       /* Drop the table nicely */
       *extension= 0;                   // Remove extension
       TABLE_LIST *table_list=(TABLE_LIST*)
-       thd->calloc(sizeof(*table_list)+ strlen(db)+strlen(file->name)+2);
+       thd->calloc(sizeof(*table_list)+ strlen(db)+strlen(file->name)+2+
+                           MYSQL50_TABLE_NAME_PREFIX_LENGTH);
       if (!table_list)
        goto err;
       table_list->db= (char*) (table_list+1);

 1. If using old 5.0 name, it should translate it to  a different table 
name in function filename_to_tablename().  The length of the table name 
(the value of "to_length")is wrong.
 2. When callocing the memory space of table_list, it  should be 
considered that it is different between file name and table name if we 
use old 5.0 name.

Test and result:
mysql> create database t1;
Query OK, 1 row affected (0.00 sec)

mysql> use t1;
Database changed

mysql> create table `#mysql50#abc``def` (id int);
Query OK, 0 rows affected (0.07 sec)

mysql> show tables;
+------------------+
| Tables_in_t2     |
+------------------+
| #mysql50#abc`def |
+------------------+
1 row in set (0.00 sec)

mysql> drop database t1;
Query OK, 1 row affected (0.01 sec)
Thread
Patch for Bug #26703Lu Jingdong30 Oct