Bug#26703: DROP DATABASE fails if database contains a #mysql50# \

	table with backticks

(Thanks to Lu Jingdong, though I did not take his patch directly, as
it contained a significant flaw.)

It wasn't a backtick/parsing problem.  We merely didn't anticipate
and allocate enough space to handle the optional "#mysql50#" table-
name prefix. 

Now, allocate that extra space in case we need it when we look up 
a legacy table to get its file's name.
parent b077981f
...@@ -91,4 +91,15 @@ create table mysql_test.`#sql-347f_7` (f1 int); ...@@ -91,4 +91,15 @@ create table mysql_test.`#sql-347f_7` (f1 int);
create table mysql_test.`#sql-347f_8` (f1 int); create table mysql_test.`#sql-347f_8` (f1 int);
drop table mysql_test.`#sql-347f_8`; drop table mysql_test.`#sql-347f_8`;
drop database mysql_test; drop database mysql_test;
create database mysqltestbug26703;
use mysqltestbug26703;
create table `#mysql50#abc``def` ( id int );
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int);
ERROR 42000: Incorrect table name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int);
create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int);
create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int);
ERROR 42000: Incorrect table name '#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
use test;
drop database mysqltestbug26703;
End of 5.1 tests End of 5.1 tests
...@@ -134,4 +134,19 @@ drop table mysql_test.`#sql-347f_8`; ...@@ -134,4 +134,19 @@ drop table mysql_test.`#sql-347f_8`;
copy_file $MYSQLTEST_VARDIR/master-data/mysql_test/t1.frm $MYSQLTEST_VARDIR/master-data/mysql_test/#sql-347f_6.frm; copy_file $MYSQLTEST_VARDIR/master-data/mysql_test/t1.frm $MYSQLTEST_VARDIR/master-data/mysql_test/#sql-347f_6.frm;
drop database mysql_test; drop database mysql_test;
#
# Bug#26703: DROP DATABASE fails if database contains a #mysql50# table with backticks
#
create database mysqltestbug26703;
use mysqltestbug26703;
create table `#mysql50#abc``def` ( id int );
--error ER_WRONG_TABLE_NAME
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int);
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int);
create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int);
--error ER_WRONG_TABLE_NAME
create table `#mysql50#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (a int);
use test;
drop database mysqltestbug26703;
--echo End of 5.1 tests --echo End of 5.1 tests
...@@ -1111,12 +1111,17 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, ...@@ -1111,12 +1111,17 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
/* Drop the table nicely */ /* Drop the table nicely */
*extension= 0; // Remove extension *extension= 0; // Remove extension
TABLE_LIST *table_list=(TABLE_LIST*) TABLE_LIST *table_list=(TABLE_LIST*)
thd->calloc(sizeof(*table_list)+ strlen(db)+strlen(file->name)+2); thd->calloc(sizeof(*table_list) +
strlen(db) + 1 +
MYSQL50_TABLE_NAME_PREFIX_LENGTH +
strlen(file->name) + 1);
if (!table_list) if (!table_list)
goto err; goto err;
table_list->db= (char*) (table_list+1); table_list->db= (char*) (table_list+1);
table_list->table_name= strmov(table_list->db, db) + 1; table_list->table_name= strmov(table_list->db, db) + 1;
VOID(filename_to_tablename(file->name, table_list->table_name, VOID(filename_to_tablename(file->name, table_list->table_name,
MYSQL50_TABLE_NAME_PREFIX_LENGTH +
strlen(file->name) + 1)); strlen(file->name) + 1));
table_list->alias= table_list->table_name; // If lower_case_table_names=2 table_list->alias= table_list->table_name; // If lower_case_table_names=2
table_list->internal_tmp_table= is_prefix(file->name, tmp_file_prefix); table_list->internal_tmp_table= is_prefix(file->name, tmp_file_prefix);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment