Commit fcb68ffe authored by Eugene Kosov's avatar Eugene Kosov Committed by Sergey Vojtovich

Simplified away READ_RECORD::struct_length

parent 5d46eeef
......@@ -582,31 +582,32 @@ static int rr_unpack_from_buffer(READ_RECORD *info)
}
/* cacheing of records from a database */
static const uint STRUCT_LENGTH= 3 + MAX_REFLENGTH;
static int init_rr_cache(THD *thd, READ_RECORD *info)
{
uint rec_cache_size, cache_records;
DBUG_ENTER("init_rr_cache");
info->struct_length= 3+MAX_REFLENGTH;
info->reclength= ALIGN_SIZE(info->table->s->reclength+1);
if (info->reclength < info->struct_length)
info->reclength= ALIGN_SIZE(info->struct_length);
if (info->reclength < STRUCT_LENGTH)
info->reclength= ALIGN_SIZE(STRUCT_LENGTH);
info->error_offset= info->table->s->reclength;
cache_records= thd->variables.read_rnd_buff_size /
(info->reclength + info->struct_length);
(info->reclength + STRUCT_LENGTH);
rec_cache_size= cache_records * info->reclength;
info->rec_cache_size= cache_records * info->ref_length;
// We have to allocate one more byte to use uint3korr (see comments for it)
if (cache_records <= 2 ||
!(info->cache= (uchar*) my_malloc_lock(rec_cache_size + cache_records *
info->struct_length + 1,
STRUCT_LENGTH + 1,
MYF(MY_THREAD_SPECIFIC))))
DBUG_RETURN(1);
#ifdef HAVE_valgrind
// Avoid warnings in qsort
bzero(info->cache, rec_cache_size + cache_records * info->struct_length + 1);
bzero(info->cache, rec_cache_size + cache_records * STRUCT_LENGTH + 1);
#endif
DBUG_PRINT("info", ("Allocated buffer for %d records", cache_records));
info->read_positions=info->cache+rec_cache_size;
......@@ -663,8 +664,7 @@ static int rr_from_cache(READ_RECORD *info)
int3store(ref_position,(long) i);
ref_position+=3;
}
my_qsort(info->read_positions, length, info->struct_length,
(qsort_cmp) rr_cmp);
my_qsort(info->read_positions, length, STRUCT_LENGTH, (qsort_cmp) rr_cmp);
position=info->read_positions;
for (i=0 ; i < length ; i++)
......
......@@ -56,7 +56,7 @@ struct READ_RECORD
Read_func read_record_func;
THD *thd;
SQL_SELECT *select;
uint ref_length,struct_length,reclength,rec_cache_size,error_offset;
uint ref_length, reclength, rec_cache_size, error_offset;
uchar *ref_pos; /* pointer to form->refpos */
uchar *record;
uchar *rec_buf; /* to read field values after filesort */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment