MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Ramil Kalimullin Date:December 11 2009 6:12pm
Subject:bzr commit into mysql-5.0-bugteam branch (ramil:2868) Bug#49465
View as plain text  
#At file:///home/ram/mysql/b49465-5.0-bugteam/ based on revid:joro@stripped

 2868 Ramil Kalimullin	2009-12-11
      Fix for bug#49465: valgrind warnings and incorrect live checksum...
      
      Problem: writing a record we don't set unused null bits in the
      record buffer in some cases. That may lead to wrong live checksum
      calculation.
      
      Fix: set unused null bits in the record buffer.
     @ mysql-test/r/myisam.result
        Fix for bug#49465: valgrind warnings and incorrect live checksum...
          - test result.
     @ mysql-test/t/myisam.test
        Fix for bug#49465: valgrind warnings and incorrect live checksum...
          - test case.
     @ sql/sql_base.cc
        Fix for bug#49465: valgrind warnings and incorrect live checksum...
          - fillrecord(): set undefined null bits in the record buffer.

    modified:
      mysql-test/r/myisam.result
      mysql-test/t/myisam.test
      sql/sql_base.cc
=== modified file 'mysql-test/r/myisam.result'
--- a/mysql-test/r/myisam.result	2008-08-26 13:48:50 +0000
+++ b/mysql-test/r/myisam.result	2009-12-11 18:12:45 +0000
@@ -1883,4 +1883,19 @@ CHECK TABLE t1;
 Table	Op	Msg_type	Msg_text
 test.t1	check	status	OK
 DROP TABLE t1;
+#
+# Bug #49465: valgrind warnings and incorrect live checksum...
+#
+CREATE TABLE t1(
+a VARCHAR(1), b VARCHAR(1), c VARCHAR(1),
+f VARCHAR(1), g VARCHAR(1), h VARCHAR(1),
+i VARCHAR(1), j VARCHAR(1), k VARCHAR(1)) CHECKSUM=1;
+INSERT INTO t1 VALUES('', '', '', '', '', '', '', '', '');
+CHECKSUM TABLE t1 QUICK;
+Table	Checksum
+test.t1	467455460
+CHECKSUM TABLE t1 EXTENDED;
+Table	Checksum
+test.t1	467455460
+DROP TABLE t1;
 End of 5.0 tests

=== modified file 'mysql-test/t/myisam.test'
--- a/mysql-test/t/myisam.test	2008-08-26 13:48:50 +0000
+++ b/mysql-test/t/myisam.test	2009-12-11 18:12:45 +0000
@@ -1225,4 +1225,18 @@ SELECT a FROM t1;
 CHECK TABLE t1;
 DROP TABLE t1; 
 
+
+--echo #
+--echo # Bug #49465: valgrind warnings and incorrect live checksum...
+--echo #
+CREATE TABLE t1(
+a VARCHAR(1), b VARCHAR(1), c VARCHAR(1),
+f VARCHAR(1), g VARCHAR(1), h VARCHAR(1),
+i VARCHAR(1), j VARCHAR(1), k VARCHAR(1)) CHECKSUM=1;
+INSERT INTO t1 VALUES('', '', '', '', '', '', '', '', '');
+CHECKSUM TABLE t1 QUICK;
+CHECKSUM TABLE t1 EXTENDED;
+DROP TABLE t1;
+
+
 --echo End of 5.0 tests

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2009-12-01 18:28:45 +0000
+++ b/sql/sql_base.cc	2009-12-11 18:12:45 +0000
@@ -5759,6 +5759,26 @@ err_no_arena:
 }
 
 
+/**                                             
+  @brief Set all unused null bits to 1 in the table record buffer.
+                                                                  
+  @param  table       TABLE object                                
+  @param  buf         record buffer
+*/
+
+static void fix_null_bits(TABLE *table, uchar *buf)
+{
+  TABLE_SHARE *share= table->s;
+  if (share->null_bytes && share->last_null_bit_pos)
+  {
+    uchar mask= 256 - (1 << share->last_null_bit_pos);
+    buf[share->null_bytes - 1]|= mask;
+    if (!(share->db_create_options & HA_OPTION_PACK_RECORD))
+      buf[0]|= 1;
+  }
+}
+
+
 /******************************************************************************
 ** Fill a record with data (for INSERT or UPDATE)
 ** Returns : 1 if some field has wrong type
@@ -5815,6 +5835,9 @@ fill_record(THD * thd, List<Item> &field
     table->auto_increment_field_not_null= FALSE;
     f.rewind();
   }
+  /* Fix undefined null bits. */
+  if (table)
+    fix_null_bits(table, (uchar *) table->record[0]);
   while ((fld= f++))
   {
     if (!(field= fld->filed_for_view_update()))
@@ -5918,6 +5941,9 @@ fill_record(THD *thd, Field **ptr, List<
     table= (*ptr)->table;
     table->auto_increment_field_not_null= FALSE;
   }
+  /* Fix undefined null bits. */
+  if (table)
+    fix_null_bits(table, (uchar *) table->record[0]);
   while ((field = *ptr++) && !thd->net.report_error)
   {
     value=v++;


Attachment: [text/bzr-bundle] bzr/ramil@mysql.com-20091211181245-622mqgkwjo6p19gz.bundle
Thread
bzr commit into mysql-5.0-bugteam branch (ramil:2868) Bug#49465Ramil Kalimullin11 Dec
  • Re: bzr commit into mysql-5.0-bugteam branch (ramil:2868) Bug#49465Sergey Vojtovich14 Dec
    • Re: bzr commit into mysql-5.0-bugteam branch (ramil:2868) Bug#49465Ramil Kalimullin <ramil@sun.com>15 Dec