#At file:///home/svoj/devel/bzr-mysql/mysql-5.1-bugteam-bug40980/ based on revid:li-bing.song@stripped
3431 Sergey Vojtovich 2010-03-30
BUG#40980 - Drop table can remove another MyISAM table's
data and index files
It was possible if DATA/INDEX DIRECTORY is pointing to
symlinked MySQL data home directory.
Do not allow to drop data/index files implicitly symlinked
to data home directory. For such tables remove symlink only.
@ mysql-test/r/symlink.result
A test case for BUG#40980.
@ mysql-test/t/symlink.test
A test case for BUG#40980.
@ storage/myisam/mi_delete_table.c
Do not allow to drop data/index files implicitly symlinked
to data home directory. For such tables remove symlink only.
modified:
mysql-test/r/symlink.result
mysql-test/t/symlink.test
storage/myisam/mi_delete_table.c
=== modified file 'mysql-test/r/symlink.result'
--- a/mysql-test/r/symlink.result 2009-10-27 13:20:34 +0000
+++ b/mysql-test/r/symlink.result 2010-03-30 15:22:39 +0000
@@ -168,4 +168,16 @@ Warning 1618 <DATA DIRECTORY> option ign
Warning 1618 <INDEX DIRECTORY> option ignored
DROP TABLE t1;
SET @@SQL_MODE=@OLD_SQL_MODE;
+#
+# BUG#40980 - Drop table can remove another MyISAM table's
+# data and index files
+#
+CREATE TABLE user(a INT) DATA DIRECTORY='MYSQL_TMP_DIR/mysql'
+ INDEX DIRECTORY='MYSQL_TMP_DIR/mysql';
+FLUSH TABLE user;
+# Symlinking mysql database to tmpdir
+FLUSH TABLE mysql.user;
+DROP TABLE user;
+FLUSH TABLE mysql.user;
+SELECT * FROM mysql.user;
End of 5.1 tests
=== modified file 'mysql-test/t/symlink.test'
--- a/mysql-test/t/symlink.test 2009-10-27 13:20:34 +0000
+++ b/mysql-test/t/symlink.test 2010-03-30 15:22:39 +0000
@@ -249,4 +249,26 @@ eval CREATE TABLE t1(a INT) DATA DIRECTO
DROP TABLE t1;
SET @@SQL_MODE=@OLD_SQL_MODE;
+--echo #
+--echo # BUG#40980 - Drop table can remove another MyISAM table's
+--echo # data and index files
+--echo #
+--mkdir $MYSQL_TMP_DIR/mysql
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+eval CREATE TABLE user(a INT) DATA DIRECTORY='$MYSQL_TMP_DIR/mysql'
+ INDEX DIRECTORY='$MYSQL_TMP_DIR/mysql';
+FLUSH TABLE user;
+--echo # Symlinking mysql database to tmpdir
+--remove_file $MYSQL_TMP_DIR/mysql/user.MYD
+--remove_file $MYSQL_TMP_DIR/mysql/user.MYI
+--rmdir $MYSQL_TMP_DIR/mysql
+--exec ln -s $MYSQLD_DATADIR/mysql $MYSQL_TMP_DIR/mysql
+FLUSH TABLE mysql.user;
+DROP TABLE user;
+FLUSH TABLE mysql.user;
+--disable_result_log
+SELECT * FROM mysql.user;
+--enable_result_log
+--remove_file $MYSQL_TMP_DIR/mysql
+
--echo End of 5.1 tests
=== modified file 'storage/myisam/mi_delete_table.c'
--- a/storage/myisam/mi_delete_table.c 2006-12-31 00:32:21 +0000
+++ b/storage/myisam/mi_delete_table.c 2010-03-30 15:22:39 +0000
@@ -58,12 +58,33 @@ int mi_delete_table(const char *name)
#endif /* USE_RAID */
fn_format(from,name,"",MI_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
- if (my_delete_with_symlink(from, MYF(MY_WME)))
- DBUG_RETURN(my_errno);
+ if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from))
+ {
+ /* Symlink is pointing to data directory. Remove symlink, keep file. */
+ if (my_delete(from, MYF(MY_WME)))
+ DBUG_RETURN(my_errno);
+ }
+ else
+ {
+ if (my_delete_with_symlink(from, MYF(MY_WME)))
+ DBUG_RETURN(my_errno);
+ }
+
fn_format(from,name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
#ifdef USE_RAID
if (raid_type)
DBUG_RETURN(my_raid_delete(from, raid_chunks, MYF(MY_WME)) ? my_errno : 0);
#endif
- DBUG_RETURN(my_delete_with_symlink(from, MYF(MY_WME)) ? my_errno : 0);
+ if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from))
+ {
+ /* Symlink is pointing to data directory. Remove symlink, keep file. */
+ if (my_delete(from, MYF(MY_WME)))
+ DBUG_RETURN(my_errno);
+ }
+ else
+ {
+ if (my_delete_with_symlink(from, MYF(MY_WME)))
+ DBUG_RETURN(my_errno);
+ }
+ DBUG_RETURN(0);
}
Attachment: [text/bzr-bundle] bzr/svoj@sun.com-20100330152239-5mdk1dsl3dlieln2.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (svoj:3431) Bug#40980 | Sergey Vojtovich | 30 Mar |