From 1ad3a05dd7353cc7106d57de1acf777cbd0368c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Aug 2007 18:23:49 +0200 Subject: Fix for errors during: "./mtr --mysqld=--default-storage-engine=maria mysqldump". First problem was use of INSERT DELAYED and MERGE tables without specifying that the tables to create should always be MyISAM. After fixing this, no rows were returned by the final SELECT of the "BUG 19025" portion of the test. Simplified problem was: LOCK TABLES `t1` WRITE; /*!40000 ALTER TABLE `t1` DISABLE KEYS */; INSERT INTO `t1` VALUES ('bla',1000),('bla',1001),('bla',1002); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; UNLOCK TABLES; select * from t1; The SELECT would find no rows. Reason: ENABLE KEYS does a maria_repair(); but data pages are still in the page cache and not on disk (because they were not flushed because maria_lock_database(F_UNLCK) was not called at the end of INSERT because under LOCK TABLES). At start of maria_repair(), sort_info.filelength is set to the physical size of the data file (=> too small because pages are in cache and not on disk). Then in sort_get_next_record(), when seeing end-of-file, this is done: sort_param->max_pos= sort_info->filelength; Further in maria_repair(), this is done: info->state->data_file_length= sort_param.max_pos; and so data_file_length is smaller (0) than reality (16384). This makes SELECT think EOF is where it is not, and thus find no rows. This is fixed by flushing all data pages at the start of maria_repair() (no performance problem is introduced as in common cases where ALTER TABLE is not under LOCK TABLES, the previous statement did this flush anyway). Another reason to do this flush is that, if not doing it, old cached pages might go down onto the repaired data file at a later point and thus corrupt it (assume a REPAIR non-QUICK). A similar bug is fixed: LOCK TABLES WRITE; INSERT; CHECK TABLE; reports "Size of datafile is: 0 Should be: 16384" again because the physical size was read without a preliminary page cache flush. mysql-test/r/maria.result: result update mysql-test/r/mysqldump.result: result update mysql-test/t/maria.test: adding test for fixed bug in LOCK TABLES + CHECK TABLE + block format. Disabling portion which hits "incorrect key file" but still letting it make the test fail (Monty to fix). mysql-test/t/mysqldump.test: in places where test expects engine to support INSERT DELAYED and be includable in a MERGE table, i.e. be MyISAM, we explicitely ask for MyISAM. storage/maria/ma_check.c: Before reading the data file's physical size with my_seek(MY_SEEK_END) during maria_chk_size() and maria_repair(), we must flush this data file, otherwise physical size is misleading and leads to - CHECK TABLE finding the table corrupted ("size of datafile should be" error) - ALTER TABLE ENABLE KEYS losing rows (maria_repair() setting data_file_length to a too small value => later SELECT does not find rows though they are in the data file). This fixes the "mysqldump.test" failure. sort_info.filelength contains the physical size, re-using it. --- mysql-test/t/mysqldump.test | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mysql-test/t/mysqldump.test') diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 0f1fee453a5..4e3b8545c76 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -199,7 +199,7 @@ DROP TABLE t1; --echo # Test for --insert-ignore --echo # -CREATE TABLE t1 (a int); +CREATE TABLE t1 (a int) ENGINE=MyISAM; INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t1 VALUES (4),(5),(6); --exec $MYSQL_DUMP --skip-comments --insert-ignore test t1 @@ -1463,8 +1463,8 @@ DROP TABLE t1; # Bug #25993: crashe with a merge table and -c # -CREATE TABLE t2 (a int); -CREATE TABLE t3 (a int); +CREATE TABLE t2 (a int) ENGINE=MyISAM; +CREATE TABLE t3 (a int) ENGINE=MyISAM; CREATE TABLE t1 (a int) ENGINE=merge UNION=(t2, t3); --exec $MYSQL_DUMP --skip-comments -c test DROP TABLE t1, t2, t3; -- cgit v1.2.1