Skip to content

Commit 1841557

Browse files
committed
myisam/aria: don't mess with IO_CACHE::file
that is, don't create a "temporary" IO_CACHE with file==-1 and manually swap it later to the valid file descriptor.
1 parent 80e61ae commit 1841557

File tree

2 files changed

+60
-57
lines changed

2 files changed

+60
-57
lines changed

storage/maria/ma_check.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4267,20 +4267,14 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
42674267

42684268
if (!(sort_info.key_block=
42694269
alloc_key_blocks(param, (uint) param->sort_key_blocks,
4270-
share->base.max_key_block_length)) ||
4271-
init_io_cache(&param->read_cache, info->dfile.file,
4270+
share->base.max_key_block_length)))
4271+
goto err;
4272+
4273+
if (init_io_cache(&param->read_cache, info->dfile.file,
42724274
(uint) param->read_buffer_length,
4273-
READ_CACHE, share->pack.header_length, 1, MYF(MY_WME)) ||
4274-
(!rep_quick &&
4275-
(init_io_cache(&info->rec_cache, info->dfile.file,
4276-
(uint) param->write_buffer_length,
4277-
WRITE_CACHE, new_header_length, 1,
4278-
MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw) ||
4279-
init_io_cache(&new_data_cache, -1,
4280-
(uint) param->write_buffer_length,
4281-
READ_CACHE, new_header_length, 1,
4282-
MYF(MY_WME | MY_DONT_CHECK_FILESIZE)))))
4275+
READ_CACHE, share->pack.header_length, 1, MYF(MY_WME)))
42834276
goto err;
4277+
42844278
sort_info.key_block_end=sort_info.key_block+param->sort_key_blocks;
42854279
info->opt_flag|=WRITE_CACHE_USED;
42864280
info->rec_cache.file= info->dfile.file; /* for sort_delete_record */
@@ -4307,7 +4301,19 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
43074301
if (param->testflag & T_UNPACK)
43084302
restore_data_file_type(share);
43094303
share->state.dellink= HA_OFFSET_ERROR;
4310-
info->rec_cache.file=new_file;
4304+
4305+
if (init_io_cache(&new_data_cache, -1,
4306+
(uint) param->write_buffer_length,
4307+
READ_CACHE, new_header_length, 1,
4308+
MYF(MY_WME | MY_DONT_CHECK_FILESIZE)))
4309+
goto err;
4310+
4311+
if (init_io_cache(&info->rec_cache, new_file,
4312+
(uint) param->write_buffer_length,
4313+
WRITE_CACHE, new_header_length, 1,
4314+
MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw))
4315+
goto err;
4316+
43114317
}
43124318

43134319
/* Optionally drop indexes and optionally modify the key_map. */

storage/myisam/mi_check.c

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,26 @@
5555
/* Functions defined in this file */
5656

5757
static int check_k_link(HA_CHECK *param, MI_INFO *info,uint nr);
58-
static int chk_index(HA_CHECK *param, MI_INFO *info,MI_KEYDEF *keyinfo,
59-
my_off_t page, uchar *buff, ha_rows *keys,
60-
ha_checksum *key_checksum, uint level);
58+
static int chk_index(HA_CHECK *, MI_INFO *, MI_KEYDEF *, my_off_t, uchar *,
59+
ha_rows *, ha_checksum *, uint);
6160
static uint isam_key_length(MI_INFO *info,MI_KEYDEF *keyinfo);
6261
static ha_checksum calc_checksum(ha_rows count);
6362
static int writekeys(MI_SORT_PARAM *sort_param);
64-
static int sort_one_index(HA_CHECK *param, MI_INFO *info,MI_KEYDEF *keyinfo,
65-
my_off_t pagepos, File new_file);
63+
static int sort_one_index(HA_CHECK *, MI_INFO *, MI_KEYDEF *, my_off_t, File);
6664
static int sort_key_read(MI_SORT_PARAM *sort_param,void *key);
6765
static int sort_ft_key_read(MI_SORT_PARAM *sort_param,void *key);
6866
static int sort_get_next_record(MI_SORT_PARAM *sort_param);
6967
static int sort_key_cmp(MI_SORT_PARAM *sort_param, const void *a,const void *b);
7068
static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a);
7169
static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a);
72-
static my_off_t get_record_for_key(MI_INFO *info,MI_KEYDEF *keyinfo,
73-
uchar *key);
74-
static int sort_insert_key(MI_SORT_PARAM *sort_param,
75-
reg1 SORT_KEY_BLOCKS *key_block,
76-
uchar *key, my_off_t prev_block);
70+
static my_off_t get_record_for_key(MI_INFO *, MI_KEYDEF *, uchar *);
71+
static int sort_insert_key(MI_SORT_PARAM *, SORT_KEY_BLOCKS *, uchar *, my_off_t);
7772
static int sort_delete_record(MI_SORT_PARAM *sort_param);
7873
/*static int flush_pending_blocks(HA_CHECK *param);*/
79-
static SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *param, uint blocks,
80-
uint buffer_length);
74+
static SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *, uint, uint);
8175
static ha_checksum mi_byte_checksum(const uchar *buf, uint length);
8276
static void set_data_file_type(MI_SORT_INFO *sort_info, MYISAM_SHARE *share);
83-
static int replace_data_file(HA_CHECK *param, MI_INFO *info,
84-
const char *name, File new_file);
77+
static int replace_data_file(HA_CHECK *, MI_INFO *, const char *, File);
8578

8679
void myisamchk_init(HA_CHECK *param)
8780
{
@@ -1545,11 +1538,6 @@ int mi_repair(HA_CHECK *param, register MI_INFO *info,
15451538
bzero(&info->rec_cache,sizeof(info->rec_cache));
15461539
goto err;
15471540
}
1548-
if (!rep_quick)
1549-
if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length,
1550-
WRITE_CACHE, new_header_length, 1,
1551-
MYF(MY_WME | MY_WAIT_IF_FULL)))
1552-
goto err;
15531541
info->opt_flag|=WRITE_CACHE_USED;
15541542
if (!mi_alloc_rec_buff(info, -1, &sort_param.record) ||
15551543
!mi_alloc_rec_buff(info, -1, &sort_param.rec_buff))
@@ -1577,12 +1565,16 @@ int mi_repair(HA_CHECK *param, register MI_INFO *info,
15771565
"datafile-header"))
15781566
goto err;
15791567
info->s->state.dellink= HA_OFFSET_ERROR;
1580-
info->rec_cache.file=new_file;
15811568
if (param->testflag & T_UNPACK)
15821569
{
15831570
share->options&= ~HA_OPTION_COMPRESS_RECORD;
15841571
mi_int2store(share->state.header.options,share->options);
15851572
}
1573+
if (init_io_cache(&info->rec_cache, new_file,
1574+
(uint) param->write_buffer_length,
1575+
WRITE_CACHE, new_header_length, 1,
1576+
MYF(MY_WME | MY_WAIT_IF_FULL)))
1577+
goto err;
15861578
}
15871579
sort_info.info=info;
15881580
sort_info.param = param;
@@ -2235,19 +2227,16 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
22352227
if (!(sort_info.key_block=
22362228
alloc_key_blocks(param,
22372229
(uint) param->sort_key_blocks,
2238-
share->base.max_key_block_length))
2239-
|| init_io_cache(&param->read_cache,info->dfile,
2230+
share->base.max_key_block_length)))
2231+
goto err;
2232+
2233+
if (init_io_cache(&param->read_cache,info->dfile,
22402234
(uint) param->read_buffer_length,
2241-
READ_CACHE,share->pack.header_length,1,MYF(MY_WME)) ||
2242-
(! rep_quick &&
2243-
init_io_cache(&info->rec_cache,info->dfile,
2244-
(uint) param->write_buffer_length,
2245-
WRITE_CACHE,new_header_length,1,
2246-
MYF((param->myf_rw & MY_WAIT_IF_FULL) | MY_WME))))
2235+
READ_CACHE,share->pack.header_length,1,MYF(MY_WME)))
22472236
goto err;
2237+
22482238
sort_info.key_block_end=sort_info.key_block+param->sort_key_blocks;
22492239
info->opt_flag|=WRITE_CACHE_USED;
2250-
info->rec_cache.file=info->dfile; /* for sort_delete_record */
22512240

22522241
if (!mi_alloc_rec_buff(info, -1, &sort_param.record) ||
22532242
!mi_alloc_rec_buff(info, -1, &sort_param.rec_buff))
@@ -2279,7 +2268,11 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
22792268
mi_int2store(share->state.header.options,share->options);
22802269
}
22812270
share->state.dellink= HA_OFFSET_ERROR;
2282-
info->rec_cache.file=new_file;
2271+
if (init_io_cache(&info->rec_cache, new_file,
2272+
(uint) param->write_buffer_length,
2273+
WRITE_CACHE, new_header_length, 1,
2274+
MYF((param->myf_rw & MY_WAIT_IF_FULL) | MY_WME)))
2275+
goto err;
22832276
}
22842277

22852278
info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
@@ -2699,23 +2692,16 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
26992692

27002693
if (!(sort_info.key_block=
27012694
alloc_key_blocks(param, (uint) param->sort_key_blocks,
2702-
share->base.max_key_block_length)) ||
2703-
init_io_cache(&param->read_cache, info->dfile,
2695+
share->base.max_key_block_length)))
2696+
goto err;
2697+
2698+
if (init_io_cache(&param->read_cache, info->dfile,
27042699
(uint) param->read_buffer_length,
2705-
READ_CACHE, share->pack.header_length, 1, MYF(MY_WME)) ||
2706-
(!rep_quick &&
2707-
(init_io_cache(&info->rec_cache, info->dfile,
2708-
(uint) param->write_buffer_length,
2709-
WRITE_CACHE, new_header_length, 1,
2710-
MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw) ||
2711-
init_io_cache(&new_data_cache, -1,
2712-
(uint) param->write_buffer_length,
2713-
READ_CACHE, new_header_length, 1,
2714-
MYF(MY_WME | MY_DONT_CHECK_FILESIZE)))))
2700+
READ_CACHE, share->pack.header_length, 1, MYF(MY_WME)))
27152701
goto err;
2702+
27162703
sort_info.key_block_end=sort_info.key_block+param->sort_key_blocks;
27172704
info->opt_flag|=WRITE_CACHE_USED;
2718-
info->rec_cache.file=info->dfile; /* for sort_delete_record */
27192705

27202706
if (!rep_quick)
27212707
{
@@ -2741,7 +2727,18 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
27412727
mi_int2store(share->state.header.options,share->options);
27422728
}
27432729
share->state.dellink= HA_OFFSET_ERROR;
2744-
info->rec_cache.file=new_file;
2730+
2731+
if (init_io_cache(&info->rec_cache, new_file,
2732+
(uint) param->write_buffer_length,
2733+
WRITE_CACHE, new_header_length, 1,
2734+
MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw))
2735+
goto err;
2736+
2737+
if (init_io_cache(&new_data_cache, -1,
2738+
(uint) param->write_buffer_length,
2739+
READ_CACHE, new_header_length, 1,
2740+
MYF(MY_WME | MY_DONT_CHECK_FILESIZE)))
2741+
goto err;
27452742
}
27462743

27472744
info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);

0 commit comments

Comments
 (0)