From 26f75ffc83e39ee915e8d4973955c950ddabb35b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Mar 2005 10:35:00 +0100 Subject: 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. --- mysql-test/t/myisam.test | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'mysql-test/t/myisam.test') diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index c8ed7910b76..0babd1f9401 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -524,3 +524,29 @@ explain select count(*) from t1 where a is null; select count(*) from t1 where a is null; drop table t1; +# +# Bug #8306: TRUNCATE leads to index corruption +# +create table t1 (c1 int, index(c1)); +create table t2 (c1 int, index(c1)) engine=merge union=(t1); +insert into t1 values (1); +# Close all tables. +flush tables; +# Open t2 and (implicitly) t1. +select * from t2; +# Truncate after flush works (unless another threads reopens t2 in between). +flush tables; +truncate table t1; +insert into t1 values (1); +# Close all tables. +flush tables; +# Open t2 and (implicitly) t1. +select * from t2; +# Truncate t1, wich was not recognized as open without the bugfix. +# Now, it should fail with a table-in-use error message. +--error 1105 +truncate table t1; +# The insert used to fail on the crashed table. +insert into t1 values (1); +drop table t1,t2; + -- cgit v1.2.1