diff options
-rw-r--r-- | mysql-test/r/drop.result | 11 | ||||
-rw-r--r-- | mysql-test/t/drop.test | 15 | ||||
-rw-r--r-- | sql/sql_db.cc | 9 |
3 files changed, 33 insertions, 2 deletions
diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index 71d6fcc7cd0..03445c51e38 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -91,4 +91,15 @@ create table mysql_test.`#sql-347f_7` (f1 int); create table mysql_test.`#sql-347f_8` (f1 int); drop table mysql_test.`#sql-347f_8`; 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 diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index a79044436eb..ad26287a666 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -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; 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 diff --git a/sql/sql_db.cc b/sql/sql_db.cc index d03ac7921ac..75f9f5e847d 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1111,12 +1111,17 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, /* 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) + 1 + + MYSQL50_TABLE_NAME_PREFIX_LENGTH + + strlen(file->name) + 1); + if (!table_list) - goto err; + goto err; table_list->db= (char*) (table_list+1); table_list->table_name= strmov(table_list->db, db) + 1; VOID(filename_to_tablename(file->name, table_list->table_name, + MYSQL50_TABLE_NAME_PREFIX_LENGTH + strlen(file->name) + 1)); 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); |