revision-id: 54411ba5caee35d0a64e727c117c222b6eef8812 (mariadb-10.2.19-98-g54411ba) parent(s): 975f4a1295f2b678c5ecea2cf4cfc69e177d88f5 committer: Alexey Botchkov timestamp: 2018-12-24 16:41:16 +0400 message: MDEV-17148 DROP DATABASE throw "Directory not empty" after changed lower_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. --- mysql-test/r/lowercase_table.result | 2 ++ mysql-test/std_data/mdev17148 | Bin 0 -> 433 bytes mysql-test/t/lowercase_table.test | 10 ++++++++++ sql/sql_db.cc | 8 ++++++-- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/lowercase_table.result b/mysql-test/r/lowercase_table.result index ac7d3e6..275edd8 100644 --- a/mysql-test/r/lowercase_table.result +++ b/mysql-test/r/lowercase_table.result @@ -127,3 +127,5 @@ Database (mysql_TE%) mysql_test drop database mysql_TEST; End of 10.0 tests +create database db1; +drop database db1; diff --git a/mysql-test/std_data/mdev17148 b/mysql-test/std_data/mdev17148 new file mode 100644 index 0000000..28ba724 Binary files /dev/null and b/mysql-test/std_data/mdev17148 differ diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test index c339105..df869af 100644 --- a/mysql-test/t/lowercase_table.test +++ b/mysql-test/t/lowercase_table.test @@ -118,3 +118,13 @@ 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; +copy_file std_data/mdev17148 $datadir/db1/T1.frm; +drop database db1; + diff --git a/sql/sql_db.cc b/sql/sql_db.cc index e3f0506..36b20f2 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1102,8 +1102,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);