55
55
/* Functions defined in this file */
56
56
57
57
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 );
61
60
static uint isam_key_length (MI_INFO * info ,MI_KEYDEF * keyinfo );
62
61
static ha_checksum calc_checksum (ha_rows count );
63
62
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 );
66
64
static int sort_key_read (MI_SORT_PARAM * sort_param ,void * key );
67
65
static int sort_ft_key_read (MI_SORT_PARAM * sort_param ,void * key );
68
66
static int sort_get_next_record (MI_SORT_PARAM * sort_param );
69
67
static int sort_key_cmp (MI_SORT_PARAM * sort_param , const void * a ,const void * b );
70
68
static int sort_ft_key_write (MI_SORT_PARAM * sort_param , const void * a );
71
69
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 );
77
72
static int sort_delete_record (MI_SORT_PARAM * sort_param );
78
73
/*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 );
81
75
static ha_checksum mi_byte_checksum (const uchar * buf , uint length );
82
76
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 );
85
78
86
79
void myisamchk_init (HA_CHECK * param )
87
80
{
@@ -1545,11 +1538,6 @@ int mi_repair(HA_CHECK *param, register MI_INFO *info,
1545
1538
bzero (& info -> rec_cache ,sizeof (info -> rec_cache ));
1546
1539
goto err ;
1547
1540
}
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 ;
1553
1541
info -> opt_flag |=WRITE_CACHE_USED ;
1554
1542
if (!mi_alloc_rec_buff (info , -1 , & sort_param .record ) ||
1555
1543
!mi_alloc_rec_buff (info , -1 , & sort_param .rec_buff ))
@@ -1577,12 +1565,16 @@ int mi_repair(HA_CHECK *param, register MI_INFO *info,
1577
1565
"datafile-header" ))
1578
1566
goto err ;
1579
1567
info -> s -> state .dellink = HA_OFFSET_ERROR ;
1580
- info -> rec_cache .file = new_file ;
1581
1568
if (param -> testflag & T_UNPACK )
1582
1569
{
1583
1570
share -> options &= ~HA_OPTION_COMPRESS_RECORD ;
1584
1571
mi_int2store (share -> state .header .options ,share -> options );
1585
1572
}
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 ;
1586
1578
}
1587
1579
sort_info .info = info ;
1588
1580
sort_info .param = param ;
@@ -2235,19 +2227,16 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
2235
2227
if (!(sort_info .key_block =
2236
2228
alloc_key_blocks (param ,
2237
2229
(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 ,
2240
2234
(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 )))
2247
2236
goto err ;
2237
+
2248
2238
sort_info .key_block_end = sort_info .key_block + param -> sort_key_blocks ;
2249
2239
info -> opt_flag |=WRITE_CACHE_USED ;
2250
- info -> rec_cache .file = info -> dfile ; /* for sort_delete_record */
2251
2240
2252
2241
if (!mi_alloc_rec_buff (info , -1 , & sort_param .record ) ||
2253
2242
!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,
2279
2268
mi_int2store (share -> state .header .options ,share -> options );
2280
2269
}
2281
2270
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 ;
2283
2276
}
2284
2277
2285
2278
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,
2699
2692
2700
2693
if (!(sort_info .key_block =
2701
2694
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 ,
2704
2699
(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 )))
2715
2701
goto err ;
2702
+
2716
2703
sort_info .key_block_end = sort_info .key_block + param -> sort_key_blocks ;
2717
2704
info -> opt_flag |=WRITE_CACHE_USED ;
2718
- info -> rec_cache .file = info -> dfile ; /* for sort_delete_record */
2719
2705
2720
2706
if (!rep_quick )
2721
2707
{
@@ -2741,7 +2727,18 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
2741
2727
mi_int2store (share -> state .header .options ,share -> options );
2742
2728
}
2743
2729
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 ;
2745
2742
}
2746
2743
2747
2744
info -> update = (short ) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED );
0 commit comments