List:Commits« Previous MessageNext Message »
From:Satya B Date:March 25 2009 9:15am
Subject:bzr commit into mysql-5.0-bugteam branch (satya.bn:2743) Bug#41541
View as plain text  
#At file:///home/satya/WORK/41541/mysql-5.0-bugteam-41541/ based on revid:azundris@stripped

 2743 Satya B	2009-03-25
      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.
      modified:
        myisam/mi_packrec.c
        mysql-test/r/myisampack.result
        mysql-test/t/myisampack.test

per-file messages:
  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
=== modified file 'myisam/mi_packrec.c'
--- a/myisam/mi_packrec.c	2009-02-10 22:47:54 +0000
+++ b/myisam/mi_packrec.c	2009-03-25 09:15:53 +0000
@@ -1430,6 +1430,32 @@ static void fill_buffer(MI_BIT_BUFF *bit
     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) +

=== modified file 'mysql-test/r/myisampack.result'
--- a/mysql-test/r/myisampack.result	2007-11-07 08:55:28 +0000
+++ b/mysql-test/r/myisampack.result	2009-03-25 09:15:53 +0000
@@ -27,3 +27,14 @@ CHECK TABLE t1 EXTENDED;
 Table	Op	Msg_type	Msg_text
 test.t1	check	status	OK
 DROP TABLE t1;
+#
+# BUG#41541 - Valgrind warnings on packed MyISAM table
+#
+CREATE TABLE  t1(f1 VARCHAR(200), f2 TEXT);
+INSERT INTO  t1 VALUES ('foo', 'foo1'), ('bar', 'bar1');
+FLUSH TABLE t1;
+# Compress the table using MYISAMPACK tool
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1024
+DROP TABLE t1;

=== modified file 'mysql-test/t/myisampack.test'
--- a/mysql-test/t/myisampack.test	2007-11-07 08:55:28 +0000
+++ b/mysql-test/t/myisampack.test	2009-03-25 09:15:53 +0000
@@ -31,3 +31,22 @@ FLUSH TABLES;
 --exec $MYISAMCHK -s --unpack $MYSQLTEST_VARDIR/master-data/test/t1
 CHECK TABLE t1 EXTENDED;
 DROP TABLE t1;
+
+--echo #
+--echo # BUG#41541 - Valgrind warnings on packed MyISAM table
+--echo #
+CREATE TABLE  t1(f1 VARCHAR(200), f2 TEXT);
+INSERT INTO  t1 VALUES ('foo', 'foo1'), ('bar', 'bar1');
+let $i=9;
+--disable_query_log
+while ($i)
+{
+ INSERT INTO t1 SELECT * FROM t1; 
+ dec $i; 
+}
+--enable_query_log
+FLUSH TABLE t1; 
+--echo # Compress the table using MYISAMPACK tool
+--exec $MYISAMPACK $MYSQLTEST_VARDIR/master-data/test/t1
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1; 

Thread
bzr commit into mysql-5.0-bugteam branch (satya.bn:2743) Bug#41541Satya B25 Mar