diff options
author | Satya B <satya.bn@sun.com> | 2009-03-25 14:45:53 +0530 |
---|---|---|
committer | Satya B <satya.bn@sun.com> | 2009-03-25 14:45:53 +0530 |
commit | ca873cd7c7d94666c4dfb533f07af3576d242294 (patch) | |
tree | a5fcab5cc1a510a6ab10046d66933795ee146085 /myisam | |
parent | aeb9747a95dd77c983d58f553637812c99507753 (diff) | |
download | mariadb-git-ca873cd7c7d94666c4dfb533f07af3576d242294.tar.gz |
Fix for BUG#41541 - Valgrind warnings on packed MyISAM table
After the table is compressed by the myisampack utility,
opening the table by the server produces valgrind warnings.
This happens because when we try to read a record into the buffer
we alway assume that the remaining buffer to read is always equal
to word size(4 or 8 or 2 bytes) we read. Sometimes we have
remaining buffer size less than word size and trying to read the
entire word size will end up in valgrind errors.
Fixed by reading byte by byte when we detect the remaining buffer
size is less than the word size.
myisam/mi_packrec.c:
Fixed fill_buffer() to read byte by byte when the remaining
buffer size is less than word size.
mysql-test/r/myisampack.result:
Result file for BUG#41541
mysql-test/t/myisampack.test:
Testcase for BUG#41541
Diffstat (limited to 'myisam')
-rw-r--r-- | myisam/mi_packrec.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c index ddcf0f33e61..df9a4d18a6c 100644 --- a/myisam/mi_packrec.c +++ b/myisam/mi_packrec.c @@ -1430,6 +1430,32 @@ static void fill_buffer(MI_BIT_BUFF *bit_buff) bit_buff->current_byte=0; return; } + else + { + uint len= 0; + uint i= 0; + /* + Check if the remaining buffer/record to read is less than the word size. + If so read byte by byte + + Note: if this branch becomes a bottleneck it can be removed, assuming + that the second memory segment allocates 7 extra bytes (see + _mi_read_pack_info()). + */ + len= bit_buff->end - bit_buff->pos; + if (len < (BITS_SAVED / 8)) + { + bit_buff->current_byte= 0; + for (i=0 ; i < len ; i++) + { + bit_buff->current_byte+= (((uint) ((uchar) bit_buff->pos[len - i - 1])) + << (8 * i)); + } + bit_buff->pos= bit_buff->end; + return; + } + } + #if BITS_SAVED == 64 bit_buff->current_byte= ((((uint) ((uchar) bit_buff->pos[7]))) + (((uint) ((uchar) bit_buff->pos[6])) << 8) + |