diff options
-rw-r--r-- | sql/records.cc | 16 | ||||
-rw-r--r-- | sql/records.h | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/sql/records.cc b/sql/records.cc index 662931f3da7..c2db29c4912 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -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++) diff --git a/sql/records.h b/sql/records.h index 534264c8223..e97f6b273cc 100644 --- a/sql/records.h +++ b/sql/records.h @@ -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 */ |