74
76
static int writekeys(MI_SORT_PARAM *sort_param);
75
77
static int sort_one_index(MI_CHECK *param, MI_INFO *info,MI_KEYDEF *keyinfo,
76
78
my_off_t pagepos, int new_file);
79
int sort_key_read(MI_SORT_PARAM *sort_param,void *key);
80
int sort_get_next_record(MI_SORT_PARAM *sort_param);
81
int sort_key_cmp(MI_SORT_PARAM *sort_param, const void *a,const void *b);
82
int sort_key_write(MI_SORT_PARAM *sort_param, const void *a);
83
my_off_t get_record_for_key(MI_INFO *info,MI_KEYDEF *keyinfo,
85
int sort_insert_key(MI_SORT_PARAM *sort_param,
86
register SORT_KEY_BLOCKS *key_block,
87
unsigned char *key, my_off_t prev_block);
88
int sort_delete_record(MI_SORT_PARAM *sort_param);
79
int sort_key_read(MI_SORT_PARAM *sort_param,void *key);
80
int sort_get_next_record(MI_SORT_PARAM *sort_param);
81
int sort_key_cmp(MI_SORT_PARAM *sort_param, const void *a,const void *b);
82
int sort_key_write(MI_SORT_PARAM *sort_param, const void *a);
83
my_off_t get_record_for_key(MI_INFO *info,MI_KEYDEF *keyinfo,
85
int sort_insert_key(MI_SORT_PARAM *sort_param,
86
register SORT_KEY_BLOCKS *key_block,
87
unsigned char *key, my_off_t prev_block);
88
int sort_delete_record(MI_SORT_PARAM *sort_param);
90
90
/*static int flush_pending_blocks(MI_CHECK *param);*/
91
91
static SORT_KEY_BLOCKS *alloc_key_blocks(MI_CHECK *param, uint32_t blocks,
92
92
uint32_t buffer_length);
1459
1459
if (!rep_quick)
1461
1461
/* Get real path for data file */
1462
if ((new_file=my_create(fn_format(param->temp_filename,
1462
if ((new_file=my_create(internal::fn_format(param->temp_filename,
1463
1463
share->data_file_name, "",
1464
1464
DATA_TMP_EXT, 2+4),
1465
1465
0,param->tmpfile_createflag,
1577
1577
if (!rep_quick)
1579
my_close(info->dfile,MYF(0));
1579
internal::my_close(info->dfile,MYF(0));
1580
1580
info->dfile=new_file;
1581
1581
info->state->data_file_length=sort_param.filepos;
1582
1582
share->state.version=(ulong) time((time_t*) 0); /* Force reopen */
1609
1609
/* Replace the actual file with the temporary file */
1610
1610
if (new_file >= 0)
1612
my_close(new_file,MYF(0));
1612
internal::my_close(new_file,MYF(0));
1613
1613
info->dfile=new_file= -1;
1614
1614
if (change_to_newfile(share->data_file_name,MI_NAME_DEXT,
1615
1615
DATA_TMP_EXT, share->base.raid_chunks,
1626
1626
llstr(sort_param.start_recpos,llbuff));
1627
1627
if (new_file >= 0)
1629
my_close(new_file,MYF(0));
1629
internal::my_close(new_file,MYF(0));
1630
1630
my_delete(param->temp_filename, MYF(MY_WME));
1631
1631
info->rec_cache.file=-1; /* don't flush data to new_file, it's closed */
1794
1794
printf("- Sorting index for MyISAM-table '%s'\n",name);
1796
1796
/* Get real path for index file */
1797
fn_format(param->temp_filename,name,"", MI_NAME_IEXT,2+4+32);
1798
if ((new_file=my_create(fn_format(param->temp_filename,param->temp_filename,
1797
internal::fn_format(param->temp_filename,name,"", MI_NAME_IEXT,2+4+32);
1798
if ((new_file=my_create(internal::fn_format(param->temp_filename,param->temp_filename,
1799
1799
"", INDEX_TMP_EXT,2+4),
1800
1800
0,param->tmpfile_createflag,MYF(0))) <= 0)
1837
1837
/* Put same locks as old file */
1838
1838
share->r_locks= share->w_locks= share->tot_locks= 0;
1839
1839
(void) _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE);
1840
my_close(share->kfile,MYF(MY_WME));
1840
internal::my_close(share->kfile,MYF(MY_WME));
1841
1841
share->kfile = -1;
1842
my_close(new_file,MYF(MY_WME));
1842
internal::my_close(new_file,MYF(MY_WME));
1843
1843
if (change_to_newfile(share->index_file_name,MI_NAME_IEXT,INDEX_TMP_EXT,0,
1845
1845
mi_open_keyfile(share))
1866
my_close(new_file,MYF(MY_WME));
1866
internal::my_close(new_file,MYF(MY_WME));
1868
1868
my_delete(param->temp_filename,MYF(MY_WME));
1952
1952
(void)raid_chunks;
1953
1953
char old_filename[FN_REFLEN],new_filename[FN_REFLEN];
1954
1954
/* Get real path to filename */
1955
(void) fn_format(old_filename,filename,"",old_ext,2+4+32);
1955
(void) internal::fn_format(old_filename,filename,"",old_ext,2+4+32);
1956
1956
return my_redel(old_filename,
1957
fn_format(new_filename,old_filename,"",new_ext,2+4),
1957
internal::fn_format(new_filename,old_filename,"",new_ext,2+4),
1958
1958
MYF(MY_WME | MY_LINK_WARNING | MyFlags));
1959
1959
} /* change_to_newfile */
2072
2072
if (!rep_quick)
2074
2074
/* Get real path for data file */
2075
if ((new_file=my_create(fn_format(param->temp_filename,
2075
if ((new_file=my_create(internal::fn_format(param->temp_filename,
2076
2076
share->data_file_name, "",
2077
2077
DATA_TMP_EXT, 2+4),
2078
2078
0,param->tmpfile_createflag,
2224
2224
sort_param.filepos;
2225
2225
/* Only whole records */
2226
2226
share->state.version=(ulong) time((time_t*) 0);
2227
my_close(info->dfile,MYF(0));
2227
internal::my_close(info->dfile,MYF(0));
2228
2228
info->dfile=new_file;
2229
2229
share->data_file_type=sort_info.new_data_file_type;
2230
2230
share->pack.header_length=(ulong) new_header_length;
2299
2299
/* Replace the actual file with the temporary file */
2300
2300
if (new_file >= 0)
2302
my_close(new_file,MYF(0));
2302
internal::my_close(new_file,MYF(0));
2303
2303
info->dfile=new_file= -1;
2304
2304
if (change_to_newfile(share->data_file_name,MI_NAME_DEXT,
2305
2305
DATA_TMP_EXT, share->base.raid_chunks,
2315
2315
mi_check_print_error(param,"%d when fixing table",errno);
2316
2316
if (new_file >= 0)
2318
my_close(new_file,MYF(0));
2318
internal::my_close(new_file,MYF(0));
2319
2319
my_delete(param->temp_filename, MYF(MY_WME));
2320
2320
if (info->dfile == new_file)
2321
2321
info->dfile= -1;
2481
2481
if (!rep_quick)
2483
2483
/* Get real path for data file */
2484
if ((new_file=my_create(fn_format(param->temp_filename,
2484
if ((new_file=my_create(internal::fn_format(param->temp_filename,
2485
2485
share->data_file_name, "",
2733
2733
Exchange the data file descriptor of the table, so that we use the
2734
2734
new file from now on.
2736
my_close(info->dfile,MYF(0));
2736
internal::my_close(info->dfile,MYF(0));
2737
2737
info->dfile=new_file;
2739
2739
share->data_file_type=sort_info.new_data_file_type;
2809
2809
/* Replace the actual file with the temporary file */
2810
2810
if (new_file >= 0)
2812
my_close(new_file,MYF(0));
2812
internal::my_close(new_file,MYF(0));
2813
2813
info->dfile=new_file= -1;
2814
2814
if (change_to_newfile(share->data_file_name,MI_NAME_DEXT,
2815
2815
DATA_TMP_EXT, share->base.raid_chunks,
2825
2825
mi_check_print_error(param,"%d when fixing table",errno);
2826
2826
if (new_file >= 0)
2828
my_close(new_file,MYF(0));
2828
internal::my_close(new_file,MYF(0));
2829
2829
my_delete(param->temp_filename, MYF(MY_WME));
2830
2830
if (info->dfile == new_file)
2831
2831
info->dfile= -1;