Bug #51327 MyISAM table is automatically repaired on ALTER
even if myisam-recover is OFF The problem was that a corrupted MyISAM table was auto repaired even if the myisam_recover_options server variable (or the myisam_recover option) was set to OFF. The reason was that the auto_repair() function, which is supposed to say if auto repair is to be used, did not use the server variable setting correctly. This bug was a regression introduced by WL#4738. This patch fixes the problem by making sure auto_repair() returns FALSE if myisam_recover_options is set to OFF. Test case added to myisam.test.
This commit is contained in:
parent
d18275c2c2
commit
e232fbe067
@ -2342,3 +2342,36 @@ Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DROP TABLE t1;
|
||||
End of 5.1 tests
|
||||
#
|
||||
# Bug#51327 MyISAM table is automatically repaired on ALTER
|
||||
# even if myisam-recover is OFF
|
||||
#
|
||||
call mtr.add_suppression("Got an error from thread_id=.*ha_myisam.cc:");
|
||||
call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table");
|
||||
call mtr.add_suppression(" '\..test.t1'");
|
||||
# Test that we can exchange a crashed partition with a table
|
||||
SELECT @@global.myisam_recover_options;
|
||||
@@global.myisam_recover_options
|
||||
OFF
|
||||
CREATE TABLE t1 (a INT, KEY (a)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
FLUSH TABLES;
|
||||
# replacing t.MYI with a corrupt + unclosed one created by doing:
|
||||
# 'create table t1 (a int key(a))' head -c1024 t1.MYI > corrupt_t1.MYI
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check warning 1 client is using or hasn't closed the table properly
|
||||
test.t1 check error Size of indexfile is: 1024 Should be: 2048
|
||||
test.t1 check warning Size of datafile is: 14 Should be: 7
|
||||
test.t1 check error Corrupt
|
||||
# Alter table should report error and not auto-repair the table.
|
||||
ALTER TABLE t1 ENGINE = MyISAM;
|
||||
ERROR HY000: Table 't1' is marked as crashed and should be repaired
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check warning Table is marked as crashed
|
||||
test.t1 check warning 1 client is using or hasn't closed the table properly
|
||||
test.t1 check error Size of indexfile is: 1024 Should be: 2048
|
||||
test.t1 check warning Size of datafile is: 14 Should be: 7
|
||||
test.t1 check error Corrupt
|
||||
DROP TABLE t1;
|
||||
|
@ -1591,3 +1591,34 @@ DROP TABLE t1;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Bug#51327 MyISAM table is automatically repaired on ALTER
|
||||
--echo # even if myisam-recover is OFF
|
||||
--echo #
|
||||
|
||||
call mtr.add_suppression("Got an error from thread_id=.*ha_myisam.cc:");
|
||||
call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table");
|
||||
call mtr.add_suppression(" '\..test.t1'");
|
||||
|
||||
let $MYSQLD_DATADIR = `SELECT @@datadir`;
|
||||
--echo # Test that we can exchange a crashed partition with a table
|
||||
SELECT @@global.myisam_recover_options;
|
||||
CREATE TABLE t1 (a INT, KEY (a)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
FLUSH TABLES;
|
||||
|
||||
--echo # replacing t.MYI with a corrupt + unclosed one created by doing:
|
||||
--echo # 'create table t1 (a int key(a))' head -c1024 t1.MYI > corrupt_t1.MYI
|
||||
--remove_file $MYSQLD_DATADIR/test/t1.MYI
|
||||
--copy_file std_data/corrupt_t1.MYI $MYSQLD_DATADIR/test/t1.MYI
|
||||
|
||||
CHECK TABLE t1;
|
||||
--echo # Alter table should report error and not auto-repair the table.
|
||||
# Remove the path to t1 to prevent platform differences
|
||||
--replace_regex /'[^']+'/'t1'/
|
||||
--error 145
|
||||
ALTER TABLE t1 ENGINE = MyISAM;
|
||||
CHECK TABLE t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2000-2006 MySQL AB
|
||||
/* Copyright (C) 2000, 2010 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
|
||||
#ifdef USE_PRAGMA_INTERFACE
|
||||
@ -124,7 +124,7 @@ class ha_myisam: public handler
|
||||
int repair(THD* thd, HA_CHECK_OPT* check_opt);
|
||||
bool check_and_repair(THD *thd);
|
||||
bool is_crashed() const;
|
||||
bool auto_repair() const { return myisam_recover_options != 0; }
|
||||
bool auto_repair() const { return myisam_recover_options != HA_RECOVER_OFF; }
|
||||
int optimize(THD* thd, HA_CHECK_OPT* check_opt);
|
||||
int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt);
|
||||
int preload_keys(THD* thd, HA_CHECK_OPT* check_opt);
|
||||
|
Loading…
x
Reference in New Issue
Block a user