summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorgkodinov/kgeorge@magare.gmz <>2007-07-11 10:49:54 +0300
committergkodinov/kgeorge@magare.gmz <>2007-07-11 10:49:54 +0300
commit015e1290a1db21e02560447ffd72238827add8f7 (patch)
treeada188315b9dd58d074fb0ee2259aa3dd1c205d7 /mysql-test
parent5b1e1eeae5f0743d8f8f01010211432a17bb04b3 (diff)
downloadmariadb-git-015e1290a1db21e02560447ffd72238827add8f7.tar.gz
Bug #29325:
By default MyISAM overwrites .MYD and .MYI files no DATA DIRECTORY option is used. This can lead to two tables using the same .MYD and .MYI files (that can't be dropped). To prevent CREATE TABLE from overwriting a file a new option is introduced : keep_files_on_create When this is on the CREATE TABLE throws an error if either the .MYD or .MYI exists for a MyISAM table. The option is off by default (resulting in compatible behavior).
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/create.result17
-rw-r--r--mysql-test/t/create.test31
2 files changed, 48 insertions, 0 deletions
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index e692dbf3938..16bc534ba92 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -1503,4 +1503,21 @@ t1 CREATE TABLE `t1` (
`c17` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+USE db2;
+INSERT INTO db2.t1 VALUES (1);
+SELECT * FROM db2.t1;
+b
+1
+RESET QUERY CACHE;
+USE db1;
+SET SESSION keep_files_on_create = TRUE;
+CREATE TABLE t1 (a INT) ENGINE MYISAM;
+ERROR HY000: Can't create/write to file './db1/t1.MYD' (Errcode: 17)
+SET SESSION keep_files_on_create = DEFAULT;
+DROP TABLE db2.t1;
+DROP DATABASE db1;
+DROP DATABASE db2;
+USE test;
End of 5.0 tests
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 99f3fea416a..610a208ebf0 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -1118,5 +1118,36 @@ show create table t1;
drop table t1;
+#
+# Bug #29325: create table overwrites .MYD file of other table (datadir)
+#
+
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+
+USE db2;
+--disable_query_log
+eval CREATE TABLE t1 (b INT) ENGINE MYISAM
+DATA DIRECTORY = '$MYSQLTEST_VARDIR/master-data/db1/';
+--enable_query_log
+
+INSERT INTO db2.t1 VALUES (1);
+SELECT * FROM db2.t1;
+RESET QUERY CACHE;
+
+USE db1;
+
+#no warning from create table
+SET SESSION keep_files_on_create = TRUE;
+--disable_abort_on_error
+CREATE TABLE t1 (a INT) ENGINE MYISAM;
+--enable_abort_on_error
+SET SESSION keep_files_on_create = DEFAULT;
+
+DROP TABLE db2.t1;
+DROP DATABASE db1;
+DROP DATABASE db2;
+USE test;
+
--echo End of 5.0 tests