Commit a50e6c9e authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-17153 server crash on repair table ... use_frm

data_file_length == 0 in mi_repair() is normal for REPAIR ... USE_FRM.
But in-file links (for blocks and deleted chain) must be compared with
the real file length to avoid spurious "link points outside datafile"
warnings and arbitrary block skipping.
parent 5139cfab
......@@ -233,3 +233,24 @@ i
UNLOCK TABLES;
DROP TABLE t1;
# End of 10.0 tests
create table t1 (a int, b varchar(200));
insert t1 select seq, repeat(200, seq) from seq_1_to_30;
delete from t1 where a % 13 = 0;
repair table t1 use_frm;
Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 28
test.t1 repair status OK
delete from t1 where a % 11 = 0;
repair table t1 extended use_frm;
Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 26
test.t1 repair status OK
delete from t1 where a % 7 = 0;
set myisam_repair_threads = 2;
repair table t1 use_frm;
Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 22
test.t1 repair status OK
set myisam_repair_threads = default;
drop table t1;
# End of 10.2 tests
#
# Test of repair table
#
--source include/have_sequence.inc
--source include/default_charset.inc
call mtr.add_suppression("character set is multi-byte");
......@@ -246,3 +247,23 @@ UNLOCK TABLES;
DROP TABLE t1;
--echo # End of 10.0 tests
#
# MDEV-17153 server crash on repair table ... use_frm
#
# Note, this test case doesn't crash, but shows spurios warnings
# unless the bug is fixed
#
create table t1 (a int, b varchar(200));
insert t1 select seq, repeat(200, seq) from seq_1_to_30;
delete from t1 where a % 13 = 0;
repair table t1 use_frm;
delete from t1 where a % 11 = 0;
repair table t1 extended use_frm;
delete from t1 where a % 7 = 0;
set myisam_repair_threads = 2;
repair table t1 use_frm;
set myisam_repair_threads = default;
drop table t1;
--echo # End of 10.2 tests
......@@ -1586,6 +1586,8 @@ int mi_repair(HA_CHECK *param, register MI_INFO *info,
sort_param.filepos=new_header_length;
param->read_cache.end_of_file=sort_info.filelength=
mysql_file_seek(info->dfile, 0L, MY_SEEK_END, MYF(0));
if (info->state->data_file_length == 0)
info->state->data_file_length= sort_info.filelength;
sort_info.dupp=0;
sort_param.fix_datafile= (my_bool) (! rep_quick);
sort_param.master=1;
......@@ -2290,6 +2292,8 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
sort_info.buff=0;
param->read_cache.end_of_file=sort_info.filelength=
mysql_file_seek(param->read_cache.file, 0L, MY_SEEK_END, MYF(0));
if (info->state->data_file_length == 0)
info->state->data_file_length= sort_info.filelength;
sort_param.wordlist=NULL;
init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0,
......@@ -2757,6 +2761,8 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
sort_info.buff=0;
param->read_cache.end_of_file=sort_info.filelength=
mysql_file_seek(param->read_cache.file, 0L, MY_SEEK_END, MYF(0));
if (info->state->data_file_length == 0)
info->state->data_file_length= sort_info.filelength;
if (share->data_file_type == DYNAMIC_RECORD)
rec_length=MY_MAX(share->base.min_pack_length+1,share->base.min_block_length);
......
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