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
parent d3dc0118
...@@ -218,7 +218,13 @@ inline double ulonglong2double(ulonglong value) ...@@ -218,7 +218,13 @@ inline double ulonglong2double(ulonglong value)
((uint32) (uchar) (A)[0]))) ((uint32) (uchar) (A)[0])))
#define sint4korr(A) (*((long *) (A))) #define sint4korr(A) (*((long *) (A)))
#define uint2korr(A) (*((uint16 *) (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 uint4korr(A) (*((unsigned long *) (A)))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[1])) << 8) +\
......
...@@ -898,7 +898,13 @@ typedef char bool; /* Ordinary boolean values 0 1 */ ...@@ -898,7 +898,13 @@ typedef char bool; /* Ordinary boolean values 0 1 */
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16)) (((uint32) ((uchar) (A)[2])) << 16))
#else #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 #endif
#define uint4korr(A) (*((unsigned long *) (A))) #define uint4korr(A) (*((unsigned long *) (A)))
#define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
......
...@@ -249,12 +249,7 @@ static int init_rr_cache(READ_RECORD *info) ...@@ -249,12 +249,7 @@ static int init_rr_cache(READ_RECORD *info)
rec_cache_size=info->cache_records*info->reclength; rec_cache_size=info->cache_records*info->reclength;
info->rec_cache_size=info->cache_records*info->ref_length; info->rec_cache_size=info->cache_records*info->ref_length;
/* // We have to allocate one more byte to use uint3korr (see comments for it)
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
*/
if (info->cache_records <= 2 || if (info->cache_records <= 2 ||
!(info->cache=(byte*) my_malloc_lock(rec_cache_size+info->cache_records* !(info->cache=(byte*) my_malloc_lock(rec_cache_size+info->cache_records*
info->struct_length+1, info->struct_length+1,
......
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