38
38
static int rr_unpack_from_buffer(ReadRecord *info);
39
39
static int rr_from_pointers(ReadRecord *info);
40
40
static int rr_from_cache(ReadRecord *info);
41
static int init_rr_cache(Session *session, ReadRecord *info);
42
41
static int rr_cmp(unsigned char *a,unsigned char *b);
43
42
static int rr_index_first(ReadRecord *info);
44
43
static int rr_index(ReadRecord *info);
130
129
!table->s->blob_fields &&
131
130
ref_length <= MAX_REFLENGTH)
133
if (! init_rr_cache(session, this))
135
134
read_record=rr_from_cache;
383
382
/* cacheing of records from a database */
384
static int init_rr_cache(Session *session, ReadRecord *info)
383
bool ReadRecord::init_rr_cache()
386
uint32_t rec_cache_size;
388
info->struct_length= 3+MAX_REFLENGTH;
389
info->reclength= ALIGN_SIZE(info->table->s->reclength+1);
390
if (info->reclength < info->struct_length)
391
info->reclength= ALIGN_SIZE(info->struct_length);
393
info->error_offset= info->table->s->reclength;
394
info->cache_records= (session->variables.read_rnd_buff_size /
395
(info->reclength+info->struct_length));
396
rec_cache_size= info->cache_records*info->reclength;
397
info->rec_cache_size= info->cache_records*info->ref_length;
385
uint32_t local_rec_cache_size;
387
struct_length= 3 + MAX_REFLENGTH;
388
reclength= ALIGN_SIZE(table->s->reclength+1);
389
if (reclength < struct_length)
390
reclength= ALIGN_SIZE(struct_length);
392
error_offset= table->s->reclength;
393
cache_records= (session->variables.read_rnd_buff_size /
394
(reclength+struct_length));
395
local_rec_cache_size= cache_records * reclength;
396
rec_cache_size= cache_records * ref_length;
399
398
// We have to allocate one more byte to use uint3korr (see comments for it)
400
if (info->cache_records <= 2 ||
401
!(info->cache=(unsigned char*) malloc(rec_cache_size+info->cache_records*
402
info->struct_length+1)))
399
if (cache_records <= 2 ||
400
!(cache=(unsigned char*) malloc(local_rec_cache_size + cache_records * struct_length + 1)))
404
404
#ifdef HAVE_purify
405
405
// Avoid warnings in qsort
406
memset(info->cache, 0,
407
rec_cache_size+info->cache_records* info->struct_length+1);
406
memset(cache, 0, local_rec_cache_size + cache_records * struct_length + 1);
409
info->read_positions=info->cache+rec_cache_size;
410
info->cache_pos=info->cache_end=info->cache;
408
read_positions= cache + local_rec_cache_size;
409
cache_pos= cache_end= cache;
412
412
} /* init_rr_cache */
414
414
static int rr_from_cache(ReadRecord *info)