summaryrefslogtreecommitdiff
path: root/sql/sql_db.cc
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.cornsilk.net>2008-03-12 12:40:12 -0400
committerunknown <cmiller@zippy.cornsilk.net>2008-03-12 12:40:12 -0400
commitb5978a9424c6213a8282713feb3734c2f92968c8 (patch)
treed15b0cd2f289b1d23496c2ae018b858b23abb8a2 /sql/sql_db.cc
parentb2a68038cecdd9881ef420fcbe984acfaa934b7a (diff)
downloadmariadb-git-b5978a9424c6213a8282713feb3734c2f92968c8.tar.gz
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. mysql-test/r/drop.result: Verify that databases with old-style files can be removed. mysql-test/t/drop.test: Verify that databases with old-style files can be removed. sql/sql_db.cc: Extend the size of the memory that holds the table's name, so that the legacy "mysql50" prefix fits.
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r--sql/sql_db.cc9
1 files changed, 7 insertions, 2 deletions
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);