From c0364263d9dcc9f122529804576f65640587acd4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Oct 2004 23:26:42 +0500 Subject: [PATCH] patch fixing after review on patch-fixing of Bug #5492 "set @@session.read_rnd_buffer_size=33554432" crashes server on query 1. added warning comments for uint3korr (need one more byte allocated) 2. unsigned long in uint3korr was replaced by unsigned int to avoid problems on 64-bits platforms 3. shorten warning comments in init_rr_cache in sql/records.cc include/config-win.h: 1. added warning comments for uint3korr (need one more byte allocated) 2. unsigned long in uint3korr was replaced by unsigned int to avoid problems on 64-bits platforms include/my_global.h: 1. added warning comments for uint3korr (need one more byte allocated) 2. unsigned long in uint3korr was replaced by unsigned int to avoid problems on 64-bits platforms sql/records.cc: shorten warning comments for my_malloc_lock in init_rr_cache --- include/config-win.h | 8 +++++++- include/my_global.h | 8 +++++++- sql/records.cc | 7 +------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/config-win.h b/include/config-win.h index bb6d663bd8d..152e85c8e68 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -218,7 +218,13 @@ inline double ulonglong2double(ulonglong value) ((uint32) (uchar) (A)[0]))) #define sint4korr(A) (*((long *) (A))) #define uint2korr(A) (*((uint16 *) (A))) -#define uint3korr(A) (long) (*((unsigned long *) (A)) & 0xFFFFFF) +/* + ATTENTION ! + + Please, note, uint3korr reads 4 bytes (not 3) ! + It means, that you have to provide enough allocated space ! +*/ +#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF) #define uint4korr(A) (*((unsigned long *) (A))) #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ (((uint32) ((uchar) (A)[1])) << 8) +\ diff --git a/include/my_global.h b/include/my_global.h index f24fc05471e..6871dfbf6c6 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -898,7 +898,13 @@ typedef char bool; /* Ordinary boolean values 0 1 */ (((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[2])) << 16)) #else -#define uint3korr(A) (long) (*((unsigned long *) (A)) & 0xFFFFFF) +/* + ATTENTION ! + + Please, note, uint3korr reads 4 bytes (not 3) ! + It means, that you have to provide enough allocated space ! +*/ +#define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF) #endif #define uint4korr(A) (*((unsigned long *) (A))) #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ diff --git a/sql/records.cc b/sql/records.cc index a2c6eb0a040..7cbb1ab3205 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -249,12 +249,7 @@ static int init_rr_cache(READ_RECORD *info) rec_cache_size=info->cache_records*info->reclength; info->rec_cache_size=info->cache_records*info->ref_length; - /* - We are going to read the last three bytes of the buffer via uint3korr - This macro reads actually 4 bytes (for speed) - So, we have to allocate one more byte at the end of the buffer - to avoid memory assertion fault - */ + // We have to allocate one more byte to use uint3korr (see comments for it) if (info->cache_records <= 2 || !(info->cache=(byte*) my_malloc_lock(rec_cache_size+info->cache_records* info->struct_length+1,