12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
16
/* Describe, check and repair of MyISAM tables */
894
894
puts("- check record links");
897
if (!mi_alloc_rec_buff(info, SIZE_MAX, &record))
897
if (!mi_alloc_rec_buff(info, -1, &record))
899
899
mi_check_print_error(param,"Not enough memory for record");
1434
1434
if (!param->using_global_keycache)
1437
if (param->read_cache.init_io_cache(info->dfile, (uint) param->read_buffer_length, READ_CACHE,share->pack.header_length,1,MYF(MY_WME)))
1437
if (init_io_cache(¶m->read_cache,info->dfile,
1438
(uint) param->read_buffer_length,
1439
READ_CACHE,share->pack.header_length,1,MYF(MY_WME)))
1439
1441
memset(&info->rec_cache, 0, sizeof(info->rec_cache));
1444
if (info->rec_cache.init_io_cache(-1, (uint) param->write_buffer_length, WRITE_CACHE, new_header_length, 1, MYF(MY_WME | MY_WAIT_IF_FULL)))
1445
if (init_io_cache(&info->rec_cache,-1,(uint) param->write_buffer_length,
1446
WRITE_CACHE, new_header_length, 1,
1447
MYF(MY_WME | MY_WAIT_IF_FULL)))
1449
1449
info->opt_flag|=WRITE_CACHE_USED;
1450
if (!mi_alloc_rec_buff(info, SIZE_MAX, &sort_param.record) ||
1451
!mi_alloc_rec_buff(info, SIZE_MAX, &sort_param.rec_buff))
1450
if (!mi_alloc_rec_buff(info, -1, &sort_param.record) ||
1451
!mi_alloc_rec_buff(info, -1, &sort_param.rec_buff))
1453
1453
mi_check_print_error(param, "Not enough memory for extra record");
1641
1641
rec_buff_ptr= NULL;
1643
1643
free(sort_info.buff);
1644
param->read_cache.end_io_cache();
1644
end_io_cache(¶m->read_cache);
1645
1645
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
1646
info->rec_cache.end_io_cache();
1646
end_io_cache(&info->rec_cache);
1647
1647
got_error|= flush_blocks(param, share->getKeyCache(), share->kfile);
1648
if (not got_error && param->testflag & T_UNPACK)
1648
if (!got_error && param->testflag & T_UNPACK)
1650
1650
share->state.header.options[0]&= (unsigned char) ~HA_OPTION_COMPRESS_RECORD;
1651
1651
share->pack.header_length=0;
2045
2045
memset(&sort_info, 0, sizeof(sort_info));
2046
2046
memset(&sort_param, 0, sizeof(sort_param));
2047
2047
if (!(sort_info.key_block=
2048
alloc_key_blocks(param, (uint) param->sort_key_blocks, share->base.max_key_block_length))
2049
|| param->read_cache.init_io_cache(info->dfile, (uint) param->read_buffer_length, READ_CACHE,share->pack.header_length,1,MYF(MY_WME))
2050
|| (! rep_quick && info->rec_cache.init_io_cache(info->dfile, (uint) param->write_buffer_length, WRITE_CACHE,new_header_length,1, MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw)))
2048
alloc_key_blocks(param,
2049
(uint) param->sort_key_blocks,
2050
share->base.max_key_block_length))
2051
|| init_io_cache(¶m->read_cache,info->dfile,
2052
(uint) param->read_buffer_length,
2053
READ_CACHE,share->pack.header_length,1,MYF(MY_WME)) ||
2055
init_io_cache(&info->rec_cache,info->dfile,
2056
(uint) param->write_buffer_length,
2057
WRITE_CACHE,new_header_length,1,
2058
MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw)))
2054
2060
sort_info.key_block_end=sort_info.key_block+param->sort_key_blocks;
2055
2061
info->opt_flag|=WRITE_CACHE_USED;
2056
2062
info->rec_cache.file=info->dfile; /* for sort_delete_record */
2058
if (!mi_alloc_rec_buff(info, SIZE_MAX, &sort_param.record) ||
2059
!mi_alloc_rec_buff(info, SIZE_MAX, &sort_param.rec_buff))
2064
if (!mi_alloc_rec_buff(info, -1, &sort_param.record) ||
2065
!mi_alloc_rec_buff(info, -1, &sort_param.rec_buff))
2061
2067
mi_check_print_error(param, "Not enough memory for extra record");
2201
2207
if (sort_param.fix_datafile)
2203
2209
param->read_cache.end_of_file=sort_param.filepos;
2204
if (write_data_suffix(&sort_info, 1) || info->rec_cache.end_io_cache())
2210
if (write_data_suffix(&sort_info,1) || end_io_cache(&info->rec_cache))
2228
2234
info->state->data_file_length=sort_param.max_pos;
2230
2236
param->read_cache.file=info->dfile; /* re-init read cache */
2231
param->read_cache.reinit_io_cache(READ_CACHE,share->pack.header_length, 1,1);
2237
reinit_io_cache(¶m->read_cache,READ_CACHE,share->pack.header_length,
2234
2241
if (param->testflag & T_WRITE_LOOP)
2288
2295
got_error|= flush_blocks(param, share->getKeyCache(), share->kfile);
2289
info->rec_cache.end_io_cache();
2296
end_io_cache(&info->rec_cache);
2290
2297
if (!got_error)
2292
2299
/* Replace the actual file with the temporary file */
2331
2338
free((unsigned char*) sort_info.key_block);
2332
2339
free(sort_info.buff);
2333
param->read_cache.end_io_cache();
2340
end_io_cache(¶m->read_cache);
2334
2341
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
2335
2342
if (!got_error && (param->testflag & T_UNPACK))
2361
2368
(info->s->rec_reflength+
2362
2369
_mi_make_key(info, sort_param->key, (unsigned char*) key,
2363
2370
sort_param->record, sort_param->filepos));
2364
#ifdef HAVE_VALGRIND
2365
2372
memset((unsigned char *)key+sort_param->real_key_length, 0,
2366
2373
(sort_param->key_length-sort_param->real_key_length));
3269
3276
We have to use an allocated buffer instead of info->rec_buff as
3270
3277
_mi_put_key_in_record() may use info->rec_buff
3272
if (!mi_alloc_rec_buff(info, SIZE_MAX, &record))
3279
if (!mi_alloc_rec_buff(info, -1, &record))
3274
3281
mi_check_print_error(param,"Not enough memory for extra record");