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

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

per-file messages:
  mysql-test/r/myisampack.result
    Result file generated for the test to check opening of myisampack 
    compressed table with varchar and text fields.
  mysql-test/t/myisampack.test
    Added testcase to check opening of myisampack compressed table 
    with varchar and text fields.
  storage/myisam/mi_packrec.c
    Fixed fill_buffer() to read byte by byte when the remaining 
    buffer size is less than word size.
=== modified file 'mysql-test/r/myisampack.result'
--- a/mysql-test/r/myisampack.result	2009-01-22 05:55:26 +0000
+++ b/mysql-test/r/myisampack.result	2009-03-04 04:28:26 +0000
@@ -54,3 +54,10 @@ test.t1	repair	error	Table 'test.t1' is 
 Warnings:
 Error	1036	Table 't1' is read only
 drop table t1;
+CREATE TABLE  t1(f1 VARCHAR(200), f2 TEXT);
+INSERT INTO  t1 VALUES ('foo', 'foo1'), ('bar', 'bar1');
+FLUSH TABLE t1;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1024
+DROP TABLE t1;

=== modified file 'mysql-test/t/myisampack.test'
--- a/mysql-test/t/myisampack.test	2009-01-30 13:44:49 +0000
+++ b/mysql-test/t/myisampack.test	2009-03-04 04:28:26 +0000
@@ -61,3 +61,21 @@ let $MYSQLD_DATADIR= `select @@datadir`;
 optimize table t1;
 repair table t1;
 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');
+let $i=9;
+--disable_query_log
+while ($i)
+{
+ INSERT INTO t1 SELECT * FROM t1; 
+ dec $i; 
+}
+--enable_query_log
+FLUSH TABLE t1; 
+--exec $MYISAMPACK $MYSQLD_DATADIR/test/t1
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1; 

=== modified file 'storage/myisam/mi_packrec.c'
--- a/storage/myisam/mi_packrec.c	2008-03-31 07:40:39 +0000
+++ b/storage/myisam/mi_packrec.c	2009-03-04 04:28:26 +0000
@@ -1425,12 +1425,35 @@ static uint fill_and_get_bits(MI_BIT_BUF
 
 static void fill_buffer(MI_BIT_BUFF *bit_buff)
 {
+  uint len= 0;
+  uint i= 0;
+
   if (bit_buff->pos >= bit_buff->end)
   {
     bit_buff->error= 1;
     bit_buff->current_byte=0;
     return;
   }
+  else 
+  {
+    /* 
+      Check if the remaining buffer/record to read is less than the word size.
+      If so read byte by byte
+    */ 
+    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) +

Thread
bzr commit into mysql-5.1-bugteam branch (satya.bn:2754) Bug#41541Satya B4 Mar
  • Re: bzr commit into mysql-5.1-bugteam branch (satya.bn:2754) Bug#41541Ingo Strüwing4 Mar
    • Re: bzr commit into mysql-5.1-bugteam branch (satya.bn:2754) Bug#41541satya4 Mar
  • Re: bzr commit into mysql-5.1-bugteam branch (satya.bn:2754) Bug#41541Sergey Vojtovich24 Mar
    • Re: bzr commit into mysql-5.1-bugteam branch (satya.bn:2754) Bug#41541satya25 Mar
  • Problems with push into mysql-6.0-bugteam branch, Bug#41541Ingo Strüwing30 Mar
    • Re: Problems with push into mysql-6.0-bugteam branch, Bug#41541satya31 Mar
      • Bug#43973 [Re: Problems with push into mysql-6.0-bugteam branch,Bug#41541]Ingo Strüwing31 Mar