diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-03-26 09:32:54 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-03-26 09:32:54 +0100 |
commit | 1b468ca675c4b978f067a443e6cd0b3c14db68cc (patch) | |
tree | 949a17662b32c95de9466071daa8e74f9d4fa8ad /storage | |
parent | f17831fa745cbd47952c6bf7d4a8eeb9195e6b6c (diff) | |
download | mariadb-git-1b468ca675c4b978f067a443e6cd0b3c14db68cc.tar.gz |
MDEV-5815 MySQL BUG#11751736: DROP DATABASE STATEMENT SHOULD REMOVE .OLD SUFFIX FROM DATABASE DIRECTORY
Delete .OLD and .TMD files when a MyISAM table is dropped.
Same for Aria.
sql/sql_db.cc:
dead code - *.TMD cannot be deleted from here.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/maria/ma_delete_table.c | 13 | ||||
-rw-r--r-- | storage/myisam/mi_delete_table.c | 53 |
2 files changed, 38 insertions, 28 deletions
diff --git a/storage/maria/ma_delete_table.c b/storage/maria/ma_delete_table.c index 09d5cde5ad0..56a6dfc8e5f 100644 --- a/storage/maria/ma_delete_table.c +++ b/storage/maria/ma_delete_table.c @@ -92,7 +92,14 @@ int maria_delete_table_files(const char *name, myf sync_dir) MYF(MY_WME | sync_dir))) DBUG_RETURN(my_errno); fn_format(from,name,"",MARIA_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); - DBUG_RETURN(mysql_file_delete_with_symlink(key_file_dfile, - from, MYF(MY_WME | sync_dir)) ? - my_errno : 0); + if (mysql_file_delete_with_symlink(key_file_dfile, from, + MYF(MY_WME | sync_dir))) + DBUG_RETURN(my_errno); + + // optional files from maria_pack: + fn_format(from,name,"",".TMD",MY_UNPACK_FILENAME|MY_APPEND_EXT); + mysql_file_delete_with_symlink(key_file_dfile, from, MYF(0)); + fn_format(from,name,"",".OLD",MY_UNPACK_FILENAME|MY_APPEND_EXT); + mysql_file_delete_with_symlink(key_file_dfile, from, MYF(0)); + DBUG_RETURN(0); } diff --git a/storage/myisam/mi_delete_table.c b/storage/myisam/mi_delete_table.c index 885990ee1be..7f351bb35a6 100644 --- a/storage/myisam/mi_delete_table.c +++ b/storage/myisam/mi_delete_table.c @@ -20,44 +20,47 @@ #include "fulltext.h" -int mi_delete_table(const char *name) +static int delete_one_file(const char *name, const char *ext, + PSI_file_key pskey, myf flags) { char from[FN_REFLEN]; - DBUG_ENTER("mi_delete_table"); - -#ifdef EXTRA_DEBUG - check_table_is_closed(name,"delete"); -#endif - - fn_format(from,name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); + DBUG_ENTER("delete_one_file"); + fn_format(from,name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT); if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from)) { /* Symlink is pointing to file in data directory. Remove symlink, keep file. */ - if (mysql_file_delete(mi_key_file_kfile, from, MYF(MY_WME))) + if (mysql_file_delete(pskey, from, flags)) DBUG_RETURN(my_errno); } else { - if (mysql_file_delete_with_symlink(mi_key_file_kfile, from, MYF(MY_WME))) - DBUG_RETURN(my_errno); - } - fn_format(from,name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); - if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from)) - { - /* - Symlink is pointing to file in data directory. - Remove symlink, keep file. - */ - if (mysql_file_delete(mi_key_file_dfile, from, MYF(MY_WME))) - DBUG_RETURN(my_errno); - } - else - { - if (mysql_file_delete_with_symlink(mi_key_file_dfile, from, MYF(MY_WME))) + if (mysql_file_delete_with_symlink(pskey, from, flags)) DBUG_RETURN(my_errno); } DBUG_RETURN(0); } + +int mi_delete_table(const char *name) +{ + int res; + DBUG_ENTER("mi_delete_table"); + +#ifdef EXTRA_DEBUG + check_table_is_closed(name,"delete"); +#endif + + if ((res= delete_one_file(name, MI_NAME_IEXT, mi_key_file_kfile, MYF(MY_WME)))) + DBUG_RETURN(res); + if ((res= delete_one_file(name, MI_NAME_DEXT, mi_key_file_dfile, MYF(MY_WME)))) + DBUG_RETURN(res); + + // optionally present: + delete_one_file(name, ".OLD", mi_key_file_dfile, MYF(0)); + delete_one_file(name, ".TMD", mi_key_file_dfile, MYF(0)); + + DBUG_RETURN(0); +} + |