From 74b064933267f58b9201c46eb67454237d7664d3 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 28 Mar 2012 13:22:21 +0300 Subject: Fixed lp:944422 "mysql_upgrade destroys Maria tables?" The issue was that check/optimize/anaylze did not zerofill the table before they started to work on it. Added one more element to not often used function handler::auto_repair() to allow handler to decide when to auto repair. mysql-test/suite/maria/r/maria-autozerofill.result: Test case for lp:944422 mysql-test/suite/maria/t/maria-autozerofill.test: Test case for lp:944422 sql/ha_partition.cc: Added argument to auto_repair() sql/ha_partition.h: Added argument to auto_repair() sql/handler.h: Added argument to auto_repair() sql/table.cc: Let auto_repair() decide which errors to trigger auto-repair storage/archive/ha_archive.h: Added argument to auto_repair() storage/csv/ha_tina.h: Added argument to auto_repair() storage/maria/ha_maria.cc: Give better error & warning messages for auto-repaired tables. storage/maria/ha_maria.h: Added argument to auto_repair() Always auto-repair in case of moved table. storage/maria/ma_open.c: Remove special handling of HA_ERR_OLD_FILE (this is now handled in auto_repair()) storage/myisam/ha_myisam.h: Added argument to auto_repair() --- mysql-test/suite/maria/r/maria-autozerofill.result | 29 ++++++++++++++++++++-- mysql-test/suite/maria/t/maria-autozerofill.test | 20 ++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/suite/maria/r/maria-autozerofill.result b/mysql-test/suite/maria/r/maria-autozerofill.result index e31cf9fa19b..7fa47814ee5 100644 --- a/mysql-test/suite/maria/r/maria-autozerofill.result +++ b/mysql-test/suite/maria/r/maria-autozerofill.result @@ -4,18 +4,43 @@ create database mysqltest; use mysqltest; create table t1(a int) engine=maria; insert into t1 values(1); -flush table t1; +create table t2 (a int) engine=maria; +INSERT INTO t2 VALUES (1),(2); +create table t3 (a int) engine=maria; +INSERT INTO t3 VALUES (1),(2); +create table t4 (a int) engine=maria; +INSERT INTO t4 VALUES (1),(2); +flush tables; create_rename_lsn has non-magic value * shut down mysqld, removed logs, restarted it select * from t1; a 1 Warnings: -Error 1194 t1' is marked as crashed and should be repaired +Note 1194 Zerofilling moved table ./mysqltest/t1 flush table t1; Status: changed,sorted index pages,zerofilled,movable create_rename_lsn has magic value insert into t1 values(2); flush table t1; create_rename_lsn has non-magic value +check table t2; +Table Op Msg_type Msg_text +mysqltest.t2 check error Table is from another system and must be zerofilled or repaired to be usable on this system +mysqltest.t2 check error Corrupt +check table t2; +Table Op Msg_type Msg_text +mysqltest.t2 check error Table is from another system and must be zerofilled or repaired to be usable on this system +mysqltest.t2 check error Corrupt +repair table t2; +Table Op Msg_type Msg_text +mysqltest.t2 repair status OK +optimize table t3; +Table Op Msg_type Msg_text +mysqltest.t3 optimize Note Zerofilling moved table ./mysqltest/t3 +mysqltest.t3 optimize status OK +analyze table t4; +Table Op Msg_type Msg_text +mysqltest.t4 analyze Note Zerofilling moved table ./mysqltest/t4 +mysqltest.t4 analyze status OK drop database mysqltest; diff --git a/mysql-test/suite/maria/t/maria-autozerofill.test b/mysql-test/suite/maria/t/maria-autozerofill.test index b46b458d89e..637b7dafe92 100644 --- a/mysql-test/suite/maria/t/maria-autozerofill.test +++ b/mysql-test/suite/maria/t/maria-autozerofill.test @@ -22,9 +22,17 @@ connection default; use mysqltest; --enable_reconnect +# Create some tables for future tests create table t1(a int) engine=maria; insert into t1 values(1); -flush table t1; +create table t2 (a int) engine=maria; +INSERT INTO t2 VALUES (1),(2); +create table t3 (a int) engine=maria; +INSERT INTO t3 VALUES (1),(2); +create table t4 (a int) engine=maria; +INSERT INTO t4 VALUES (1),(2); +flush tables; + # Check that table is not zerofilled, not movable let $MYSQLD_DATADIR= `select @@datadir`; --exec $MARIA_CHK -dv $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt @@ -80,4 +88,14 @@ perl; close FILE; EOF +# +# BUG#44422 "mysql_upgrade destroys Maria tables?" +# Check repair and optimize of moved table +# +check table t2; +check table t2; +repair table t2; +optimize table t3; +analyze table t4; + drop database mysqltest; -- cgit v1.2.1