From 6d5dd31584d984686fefa1ae3271deeedcc34cc6 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov Date: Tue, 1 Dec 2009 16:42:28 +0300 Subject: [PATCH] Backport of: ---------------------------------------------------------- revno: 2630.2.20 committer: Konstantin Osipov branch nick: mysql-6.0-runtime timestamp: Fri 2008-06-27 20:10:42 +0400 message: Fix a regression introduced by WL#3726 when a table was left in the table cache after DROP DATABASE. Implementation of DROP DATABASE reads a list of files in the database directory and constructs from it the list of tables to be dropped. If the filesystem is case-insensitive and case-preserving, the table names should be lowercased, because the same has been done when entries for them were inserted into the table cache. Skipping this step will lead to orphaned TABLEs left in the table cache. Fixes lowercase_table2 failure on powermacg5. sql/sql_db.cc: Lowercase the table name, it's used to construct the table cache key. --- sql/sql_db.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 44909880da0..b5c51601faf 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1142,6 +1142,11 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, (void) filename_to_tablename(file->name, table_list->table_name, MYSQL50_TABLE_NAME_PREFIX_LENGTH + strlen(file->name) + 1); + + /* To be able to correctly look up the table in the table cache. */ + if (lower_case_table_names) + my_casedn_str(files_charset_info, table_list->table_name); + 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); /* Link into list */