@@ -582,31 +582,32 @@ static int rr_unpack_from_buffer(READ_RECORD *info)
582
582
}
583
583
/* cacheing of records from a database */
584
584
585
+ static const uint STRUCT_LENGTH= 3 + MAX_REFLENGTH;
586
+
585
587
static int init_rr_cache (THD *thd, READ_RECORD *info)
586
588
{
587
589
uint rec_cache_size, cache_records;
588
590
DBUG_ENTER (" init_rr_cache" );
589
591
590
- info->struct_length = 3 +MAX_REFLENGTH;
591
592
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 );
594
595
595
596
info->error_offset = info->table ->s ->reclength ;
596
597
cache_records= thd->variables .read_rnd_buff_size /
597
- (info->reclength + info-> struct_length );
598
+ (info->reclength + STRUCT_LENGTH );
598
599
rec_cache_size= cache_records * info->reclength ;
599
600
info->rec_cache_size = cache_records * info->ref_length ;
600
601
601
602
// We have to allocate one more byte to use uint3korr (see comments for it)
602
603
if (cache_records <= 2 ||
603
604
!(info->cache = (uchar*) my_malloc_lock (rec_cache_size + cache_records *
604
- info-> struct_length + 1 ,
605
+ STRUCT_LENGTH + 1 ,
605
606
MYF (MY_THREAD_SPECIFIC))))
606
607
DBUG_RETURN (1 );
607
608
#ifdef HAVE_valgrind
608
609
// 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 );
610
611
#endif
611
612
DBUG_PRINT (" info" , (" Allocated buffer for %d records" , cache_records));
612
613
info->read_positions =info->cache +rec_cache_size;
@@ -663,8 +664,7 @@ static int rr_from_cache(READ_RECORD *info)
663
664
int3store (ref_position,(long ) i);
664
665
ref_position+=3 ;
665
666
}
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);
668
668
669
669
position=info->read_positions ;
670
670
for (i=0 ; i < length ; i++)
0 commit comments