Skip to content

Commit

Permalink
MDEV-17148 DROP DATABASE throw "Directory not empty" after changed lo…
Browse files Browse the repository at this point in the history
…wer_case_table_names.

No need to lowercase table names on case-sensitive file systems, as the
cache won't contain the 'lowercased' table anyway. And it prevents the
UPPERCASE.frm from being deleted.
  • Loading branch information
Alexey Botchkov committed Feb 1, 2019
1 parent 7c7161a commit 09cea87
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions mysql-test/r/lowercase_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,7 @@ Database (mysql_TE%)
mysql_test
drop database mysql_TEST;
End of 10.0 tests
create database db1;
create table t1 (a int);
drop database db1;
drop table t1;
12 changes: 12 additions & 0 deletions mysql-test/t/lowercase_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,15 @@ show databases like "mysql_TE%";
drop database mysql_TEST;

--echo End of 10.0 tests

#
# MDEV-17148 DROP DATABASE throw "Directory not empty" after changed lower_case_table_names.
#

let $datadir=`select @@datadir`;
create database db1;
create table t1 (a int);
copy_file $datadir/test/t1.frm $datadir/db1/T1.frm;
drop database db1;
drop table t1;

8 changes: 6 additions & 2 deletions sql/sql_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1107,8 +1107,12 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
table_list->table_name_length= table->length;
table_list->open_type= OT_BASE_ONLY;

/* To be able to correctly look up the table in the table cache. */
if (lower_case_table_names)
/*
On the case-insensitive file systems table is opened
with the lowercased file name. So we should lowercase
as well to look up the cache properly.
*/
if (lower_case_file_system)
table_list->table_name_length= my_casedn_str(files_charset_info,
table_list->table_name);

Expand Down

0 comments on commit 09cea87

Please sign in to comment.