Commit 1b468ca6 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-5815 MySQL BUG#11751736: DROP DATABASE STATEMENT SHOULD REMOVE .OLD...

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.
parent f17831fa
......@@ -150,3 +150,10 @@ CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
#
# BUG#11751736: DROP DATABASE STATEMENT SHOULD REMOVE .OLD SUFFIX FROM
# DATABASE DIRECTORY
#
CREATE DATABASE db1;
CREATE TABLE db1.t1(c1 INT) ENGINE=MyISAM;
DROP DATABASE db1;
......@@ -267,3 +267,15 @@ FLUSH TABLE t1;
--exec $MYISAMCHK -soq $MYSQLD_DATADIR/test/t1
CHECK TABLE t1;
DROP TABLE t1;
--echo #
--echo # BUG#11751736: DROP DATABASE STATEMENT SHOULD REMOVE .OLD SUFFIX FROM
--echo # DATABASE DIRECTORY
--echo #
CREATE DATABASE db1;
CREATE TABLE db1.t1(c1 INT) ENGINE=MyISAM;
## Added -f to force pack db in any case regardless the size of database
## being packed
let $MYSQLD_DATADIR = `SELECT @@datadir`;
--exec $MYISAMPACK -b -f $MYSQLD_DATADIR/db1/t1
DROP DATABASE db1;
......@@ -49,7 +49,7 @@
#define MAX_DROP_TABLE_Q_LEN 1024
const char *del_exts[]= {".BAK", ".TMD",".opt", NullS};
const char *del_exts[]= {".BAK", ".opt", NullS};
static TYPELIB deletable_extentions=
{array_elements(del_exts)-1,"del_exts", del_exts, NULL};
......
......@@ -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);
}
......@@ -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);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment