summaryrefslogtreecommitdiff
path: root/myisam/mi_create.c
diff options
context:
space:
mode:
authorunknown <ingo@mysql.com>2005-03-02 10:35:00 +0100
committerunknown <ingo@mysql.com>2005-03-02 10:35:00 +0100
commit26f75ffc83e39ee915e8d4973955c950ddabb35b (patch)
tree26e67311fd029bf9026836ac8fe24ecb83ac29e1 /myisam/mi_create.c
parent22e0b300a47321ec8dfef0bb8bc5f7c0f1449ce1 (diff)
downloadmariadb-git-26f75ffc83e39ee915e8d4973955c950ddabb35b.tar.gz
Bug#8306 - TRUNCATE leads to index corruption
Added a check, if the table, which we are going to create, is open. This can happen if a MERGE mapped table is TRUNCATEd. myisam/mi_open.c: Bug#8306 - TRUNCATE leads to index corruption Made test_if_reopen() globally available. myisam/myisamdef.h: Bug#8306 - TRUNCATE leads to index corruption Declared test_if_reopen() as globally available. mysql-test/r/myisam.result: Bug#8306 - TRUNCATE leads to index corruption The test result. mysql-test/t/myisam.test: Bug#8306 - TRUNCATE leads to index corruption The test case.
Diffstat (limited to 'myisam/mi_create.c')
-rw-r--r--myisam/mi_create.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/myisam/mi_create.c b/myisam/mi_create.c
index f99a2c655d2..da3330627a7 100644
--- a/myisam/mi_create.c
+++ b/myisam/mi_create.c
@@ -533,6 +533,21 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
create_flag=MY_DELETE_OLD;
}
+ /*
+ If a MRG_MyISAM table is in use, the mapped MyISAM tables are open,
+ but no entry is made in the table cache for them.
+ A TRUNCATE command checks for the table in the cache only and could
+ be fooled to believe, the table is not open.
+ Pull the emergency brake in this situation. (Bug #8306)
+ */
+ if (test_if_reopen(filename))
+ {
+ my_printf_error(0, "MyISAM table '%s' is in use "
+ "(most likely by a MERGE table). Try FLUSH TABLES.",
+ MYF(0), name + dirname_length(name));
+ goto err;
+ }
+
if ((file= my_create_with_symlink(linkname_ptr,
filename,
0, O_RDWR | O_TRUNC,