Commit bded6a7f authored by Sergey Vojtovich's avatar Sergey Vojtovich

Merge fix for BUG46565 to mysql-5.1-bugteam.

parents d5325c77 298c067e
...@@ -12737,3 +12737,22 @@ SELECT * FROM t1; ...@@ -12737,3 +12737,22 @@ SELECT * FROM t1;
ERROR HY000: Can't find file: 't1' (errno: 2) ERROR HY000: Can't find file: 't1' (errno: 2)
DROP TABLE t1; DROP TABLE t1;
ERROR 42S02: Unknown table 't1' ERROR 42S02: Unknown table 't1'
#
# BUG#46565 - repair of partition fail for archive engine
#
# Installing corrupted table files for t1.
SELECT * FROM t1;
ERROR HY000: Table 't1' is marked as crashed and should be repaired
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair error Corrupt
SELECT * FROM t1;
ERROR HY000: Table 't1' is marked as crashed and should be repaired
REPAIR TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 repair status OK
SELECT * FROM t1;
a
1
2
DROP TABLE t1;
...@@ -1655,3 +1655,26 @@ FLUSH TABLE t1; ...@@ -1655,3 +1655,26 @@ FLUSH TABLE t1;
SELECT * FROM t1; SELECT * FROM t1;
--error ER_BAD_TABLE_ERROR --error ER_BAD_TABLE_ERROR
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # BUG#46565 - repair of partition fail for archive engine
--echo #
--echo # Installing corrupted table files for t1.
# bug46565 was created, filled and damaged as following:
# CREATE TABLE bug46565(a INT) ENGINE=archive;
# INSERT INTO bug46565 VALUES(1);
# FLUSH TABLE bug46565;
# INSERT INTO bug46565 VALUES(2),(3);
# FLUSH TABLE bug46565;
# dd if=bug46565.ARZ of=std_data/bug46565.ARZ bs=1 count=8670
copy_file std_data/bug46565.frm $MYSQLD_DATADIR/test/t1.frm;
copy_file std_data/bug46565.ARZ $MYSQLD_DATADIR/test/t1.ARZ;
--error ER_CRASHED_ON_USAGE
SELECT * FROM t1;
REPAIR TABLE t1;
--error ER_CRASHED_ON_USAGE
SELECT * FROM t1;
REPAIR TABLE t1 EXTENDED;
SELECT * FROM t1;
DROP TABLE t1;
...@@ -1269,13 +1269,12 @@ int ha_archive::rnd_pos(uchar * buf, uchar *pos) ...@@ -1269,13 +1269,12 @@ int ha_archive::rnd_pos(uchar * buf, uchar *pos)
/* /*
This method repairs the meta file. It does this by walking the datafile and This method repairs the meta file. It does this by walking the datafile and
rewriting the meta file. Currently it does this by calling optimize with rewriting the meta file. If EXTENDED repair is requested, we attempt to
the extended flag. recover as much data as possible.
*/ */
int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt) int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt)
{ {
DBUG_ENTER("ha_archive::repair"); DBUG_ENTER("ha_archive::repair");
check_opt->flags= T_EXTEND;
int rc= optimize(thd, check_opt); int rc= optimize(thd, check_opt);
if (rc) if (rc)
...@@ -1369,7 +1368,14 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) ...@@ -1369,7 +1368,14 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
DBUG_PRINT("ha_archive", ("recovered %llu archive rows", DBUG_PRINT("ha_archive", ("recovered %llu archive rows",
(unsigned long long)share->rows_recorded)); (unsigned long long)share->rows_recorded));
if (rc && rc != HA_ERR_END_OF_FILE) /*
If REPAIR ... EXTENDED is requested, try to recover as much data
from data file as possible. In this case if we failed to read a
record, we assume EOF. This allows massive data loss, but we can
hardly do more with broken zlib stream. And this is the only way
to restore at least what is still recoverable.
*/
if (rc && rc != HA_ERR_END_OF_FILE && !(check_opt->flags & T_EXTEND))
goto error; goto error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment