summaryrefslogtreecommitdiff
path: root/sql/sql_db.cc
diff options
context:
space:
mode:
authorMagne Mahre <magne.mahre@sun.com>2010-10-19 12:27:09 +0200
committerMagne Mahre <magne.mahre@sun.com>2010-10-19 12:27:09 +0200
commit1c68d2efe72b8663fb3cfba91667179d142e81be (patch)
treeb64d6b5ca6462d7dedeebc0abef3c8704d91502a /sql/sql_db.cc
parent6da8a65bf0ebeb74f8fdd9a83c8650745e811aaa (diff)
downloadmariadb-git-1c68d2efe72b8663fb3cfba91667179d142e81be.tar.gz
Bug #46941 crash with lower_case_table_names=2 and foreign key
data dictionary confusion On file systems with case insensitive file names, and lower_case_table_names set to '2', the server could crash due to a table definition cache inconsistency. This is the default setting on MacOSX, but may also be set and used on MS Windows. The bug is caused by using two different strategies for creating the hash key for the table definition cache, resulting in failure to look up an entry which is present in the cache, or failure to delete an existing entry. One strategy was to use the real table name (with case preserved), and the other to use a normalized table name (i.e a lower case version). This is manifested in two cases. One is during 'DROP DATABASE', where all known files are removed. The removal from the table definition cache is done via a generated list of TABLE_LIST with keys (wrongly) created using the case preserved name. The other is during CREATE TABLE, where the cache lookup is also (wrongly) based on the case preserved name. The fix was to use only the normalized table name when creating hash keys.
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r--sql/sql_db.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index d3435b891b1..2c44c1a8449 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -1197,6 +1197,12 @@ 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)
+ table_list->table_name_length= 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 */