Skip to content

Commit fcb68ff

Browse files
kevgssvoj
authored andcommitted
Simplified away READ_RECORD::struct_length
1 parent 5d46eee commit fcb68ff

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

sql/records.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -582,31 +582,32 @@ static int rr_unpack_from_buffer(READ_RECORD *info)
582582
}
583583
/* cacheing of records from a database */
584584

585+
static const uint STRUCT_LENGTH= 3 + MAX_REFLENGTH;
586+
585587
static int init_rr_cache(THD *thd, READ_RECORD *info)
586588
{
587589
uint rec_cache_size, cache_records;
588590
DBUG_ENTER("init_rr_cache");
589591

590-
info->struct_length= 3+MAX_REFLENGTH;
591592
info->reclength= ALIGN_SIZE(info->table->s->reclength+1);
592-
if (info->reclength < info->struct_length)
593-
info->reclength= ALIGN_SIZE(info->struct_length);
593+
if (info->reclength < STRUCT_LENGTH)
594+
info->reclength= ALIGN_SIZE(STRUCT_LENGTH);
594595

595596
info->error_offset= info->table->s->reclength;
596597
cache_records= thd->variables.read_rnd_buff_size /
597-
(info->reclength + info->struct_length);
598+
(info->reclength + STRUCT_LENGTH);
598599
rec_cache_size= cache_records * info->reclength;
599600
info->rec_cache_size= cache_records * info->ref_length;
600601

601602
// We have to allocate one more byte to use uint3korr (see comments for it)
602603
if (cache_records <= 2 ||
603604
!(info->cache= (uchar*) my_malloc_lock(rec_cache_size + cache_records *
604-
info->struct_length + 1,
605+
STRUCT_LENGTH + 1,
605606
MYF(MY_THREAD_SPECIFIC))))
606607
DBUG_RETURN(1);
607608
#ifdef HAVE_valgrind
608609
// Avoid warnings in qsort
609-
bzero(info->cache, rec_cache_size + cache_records * info->struct_length + 1);
610+
bzero(info->cache, rec_cache_size + cache_records * STRUCT_LENGTH + 1);
610611
#endif
611612
DBUG_PRINT("info", ("Allocated buffer for %d records", cache_records));
612613
info->read_positions=info->cache+rec_cache_size;
@@ -663,8 +664,7 @@ static int rr_from_cache(READ_RECORD *info)
663664
int3store(ref_position,(long) i);
664665
ref_position+=3;
665666
}
666-
my_qsort(info->read_positions, length, info->struct_length,
667-
(qsort_cmp) rr_cmp);
667+
my_qsort(info->read_positions, length, STRUCT_LENGTH, (qsort_cmp) rr_cmp);
668668

669669
position=info->read_positions;
670670
for (i=0 ; i < length ; i++)

sql/records.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct READ_RECORD
5656
Read_func read_record_func;
5757
THD *thd;
5858
SQL_SELECT *select;
59-
uint ref_length,struct_length,reclength,rec_cache_size,error_offset;
59+
uint ref_length, reclength, rec_cache_size, error_offset;
6060
uchar *ref_pos; /* pointer to form->refpos */
6161
uchar *record;
6262
uchar *rec_buf; /* to read field values after filesort */

0 commit comments

Comments
 (0)