diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-05-27 21:43:25 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-06-02 18:53:36 +0200 |
commit | 1841557e407038e3611b0788eaf70fd3d8eb043e (patch) | |
tree | 0a7704c3febe0bcc10d472865bb639deb79ac3a9 | |
parent | 80e61ae21e2373ee73407f91f596b11c2c46e7d9 (diff) | |
download | mariadb-git-1841557e407038e3611b0788eaf70fd3d8eb043e.tar.gz |
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.
-rw-r--r-- | storage/maria/ma_check.c | 32 | ||||
-rw-r--r-- | storage/myisam/mi_check.c | 85 |
2 files changed, 60 insertions, 57 deletions
diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 8c012d21095..644813ce85c 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -4267,20 +4267,14 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, if (!(sort_info.key_block= alloc_key_blocks(param, (uint) param->sort_key_blocks, - share->base.max_key_block_length)) || - init_io_cache(¶m->read_cache, info->dfile.file, + share->base.max_key_block_length))) + goto err; + + if (init_io_cache(¶m->read_cache, info->dfile.file, (uint) param->read_buffer_length, - READ_CACHE, share->pack.header_length, 1, MYF(MY_WME)) || - (!rep_quick && - (init_io_cache(&info->rec_cache, info->dfile.file, - (uint) param->write_buffer_length, - WRITE_CACHE, new_header_length, 1, - MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw) || - init_io_cache(&new_data_cache, -1, - (uint) param->write_buffer_length, - READ_CACHE, new_header_length, 1, - MYF(MY_WME | MY_DONT_CHECK_FILESIZE))))) + READ_CACHE, share->pack.header_length, 1, MYF(MY_WME))) goto err; + sort_info.key_block_end=sort_info.key_block+param->sort_key_blocks; info->opt_flag|=WRITE_CACHE_USED; 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, if (param->testflag & T_UNPACK) restore_data_file_type(share); share->state.dellink= HA_OFFSET_ERROR; - info->rec_cache.file=new_file; + + if (init_io_cache(&new_data_cache, -1, + (uint) param->write_buffer_length, + READ_CACHE, new_header_length, 1, + MYF(MY_WME | MY_DONT_CHECK_FILESIZE))) + goto err; + + if (init_io_cache(&info->rec_cache, new_file, + (uint) param->write_buffer_length, + WRITE_CACHE, new_header_length, 1, + MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw)) + goto err; + } /* Optionally drop indexes and optionally modify the key_map. */ diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index be0b90b4bad..c38e7378015 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -55,33 +55,26 @@ /* Functions defined in this file */ static int check_k_link(HA_CHECK *param, MI_INFO *info,uint nr); -static int chk_index(HA_CHECK *param, MI_INFO *info,MI_KEYDEF *keyinfo, - my_off_t page, uchar *buff, ha_rows *keys, - ha_checksum *key_checksum, uint level); +static int chk_index(HA_CHECK *, MI_INFO *, MI_KEYDEF *, my_off_t, uchar *, + ha_rows *, ha_checksum *, uint); static uint isam_key_length(MI_INFO *info,MI_KEYDEF *keyinfo); static ha_checksum calc_checksum(ha_rows count); static int writekeys(MI_SORT_PARAM *sort_param); -static int sort_one_index(HA_CHECK *param, MI_INFO *info,MI_KEYDEF *keyinfo, - my_off_t pagepos, File new_file); +static int sort_one_index(HA_CHECK *, MI_INFO *, MI_KEYDEF *, my_off_t, File); static int sort_key_read(MI_SORT_PARAM *sort_param,void *key); static int sort_ft_key_read(MI_SORT_PARAM *sort_param,void *key); static int sort_get_next_record(MI_SORT_PARAM *sort_param); static int sort_key_cmp(MI_SORT_PARAM *sort_param, const void *a,const void *b); static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a); static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a); -static my_off_t get_record_for_key(MI_INFO *info,MI_KEYDEF *keyinfo, - uchar *key); -static int sort_insert_key(MI_SORT_PARAM *sort_param, - reg1 SORT_KEY_BLOCKS *key_block, - uchar *key, my_off_t prev_block); +static my_off_t get_record_for_key(MI_INFO *, MI_KEYDEF *, uchar *); +static int sort_insert_key(MI_SORT_PARAM *, SORT_KEY_BLOCKS *, uchar *, my_off_t); static int sort_delete_record(MI_SORT_PARAM *sort_param); /*static int flush_pending_blocks(HA_CHECK *param);*/ -static SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *param, uint blocks, - uint buffer_length); +static SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *, uint, uint); static ha_checksum mi_byte_checksum(const uchar *buf, uint length); static void set_data_file_type(MI_SORT_INFO *sort_info, MYISAM_SHARE *share); -static int replace_data_file(HA_CHECK *param, MI_INFO *info, - const char *name, File new_file); +static int replace_data_file(HA_CHECK *, MI_INFO *, const char *, File); void myisamchk_init(HA_CHECK *param) { @@ -1545,11 +1538,6 @@ int mi_repair(HA_CHECK *param, register MI_INFO *info, bzero(&info->rec_cache,sizeof(info->rec_cache)); goto err; } - if (!rep_quick) - if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length, - WRITE_CACHE, new_header_length, 1, - MYF(MY_WME | MY_WAIT_IF_FULL))) - goto err; info->opt_flag|=WRITE_CACHE_USED; if (!mi_alloc_rec_buff(info, -1, &sort_param.record) || !mi_alloc_rec_buff(info, -1, &sort_param.rec_buff)) @@ -1577,12 +1565,16 @@ int mi_repair(HA_CHECK *param, register MI_INFO *info, "datafile-header")) goto err; info->s->state.dellink= HA_OFFSET_ERROR; - info->rec_cache.file=new_file; if (param->testflag & T_UNPACK) { share->options&= ~HA_OPTION_COMPRESS_RECORD; mi_int2store(share->state.header.options,share->options); } + if (init_io_cache(&info->rec_cache, new_file, + (uint) param->write_buffer_length, + WRITE_CACHE, new_header_length, 1, + MYF(MY_WME | MY_WAIT_IF_FULL))) + goto err; } sort_info.info=info; sort_info.param = param; @@ -2235,19 +2227,16 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info, if (!(sort_info.key_block= alloc_key_blocks(param, (uint) param->sort_key_blocks, - share->base.max_key_block_length)) - || init_io_cache(¶m->read_cache,info->dfile, + share->base.max_key_block_length))) + goto err; + + if (init_io_cache(¶m->read_cache,info->dfile, (uint) param->read_buffer_length, - READ_CACHE,share->pack.header_length,1,MYF(MY_WME)) || - (! rep_quick && - init_io_cache(&info->rec_cache,info->dfile, - (uint) param->write_buffer_length, - WRITE_CACHE,new_header_length,1, - MYF((param->myf_rw & MY_WAIT_IF_FULL) | MY_WME)))) + READ_CACHE,share->pack.header_length,1,MYF(MY_WME))) goto err; + sort_info.key_block_end=sort_info.key_block+param->sort_key_blocks; info->opt_flag|=WRITE_CACHE_USED; - info->rec_cache.file=info->dfile; /* for sort_delete_record */ if (!mi_alloc_rec_buff(info, -1, &sort_param.record) || !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, mi_int2store(share->state.header.options,share->options); } share->state.dellink= HA_OFFSET_ERROR; - info->rec_cache.file=new_file; + if (init_io_cache(&info->rec_cache, new_file, + (uint) param->write_buffer_length, + WRITE_CACHE, new_header_length, 1, + MYF((param->myf_rw & MY_WAIT_IF_FULL) | MY_WME))) + goto err; } 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, if (!(sort_info.key_block= alloc_key_blocks(param, (uint) param->sort_key_blocks, - share->base.max_key_block_length)) || - init_io_cache(¶m->read_cache, info->dfile, + share->base.max_key_block_length))) + goto err; + + if (init_io_cache(¶m->read_cache, info->dfile, (uint) param->read_buffer_length, - READ_CACHE, share->pack.header_length, 1, MYF(MY_WME)) || - (!rep_quick && - (init_io_cache(&info->rec_cache, info->dfile, - (uint) param->write_buffer_length, - WRITE_CACHE, new_header_length, 1, - MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw) || - init_io_cache(&new_data_cache, -1, - (uint) param->write_buffer_length, - READ_CACHE, new_header_length, 1, - MYF(MY_WME | MY_DONT_CHECK_FILESIZE))))) + READ_CACHE, share->pack.header_length, 1, MYF(MY_WME))) goto err; + sort_info.key_block_end=sort_info.key_block+param->sort_key_blocks; info->opt_flag|=WRITE_CACHE_USED; - info->rec_cache.file=info->dfile; /* for sort_delete_record */ if (!rep_quick) { @@ -2741,7 +2727,18 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, mi_int2store(share->state.header.options,share->options); } share->state.dellink= HA_OFFSET_ERROR; - info->rec_cache.file=new_file; + + if (init_io_cache(&info->rec_cache, new_file, + (uint) param->write_buffer_length, + WRITE_CACHE, new_header_length, 1, + MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw)) + goto err; + + if (init_io_cache(&new_data_cache, -1, + (uint) param->write_buffer_length, + READ_CACHE, new_header_length, 1, + MYF(MY_WME | MY_DONT_CHECK_FILESIZE))) + goto err; } info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); |