MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:February 11 2010 9:57am
Subject:bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:3372)
Bug#50591
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.1-bug-48884/ based on revid:luis.soares@stripped

 3372 Sergey Glukhov	2010-02-11
      Bug#50591 bit(31) causes Duplicate entry '1-NULL' for key 'group_key'
      The problem is that during temporary table creation uneven bits
      are not taken into account for hidden fields. It leads to incorrect
      calculation&allocation of null bytes size for table record. And
      if grouped value is null we set wrong bit for this value(see end_update()).
      Fixed by adding separate calculation of uneven bit for hidden fields.
     @ mysql-test/r/type_bit.result
        test result
     @ mysql-test/t/type_bit.test
        test case
     @ sql/sql_select.cc
        added separate calculation of uneven bit for hidden fields

    modified:
      mysql-test/r/type_bit.result
      mysql-test/t/type_bit.test
      sql/sql_select.cc
=== modified file 'mysql-test/r/type_bit.result'
--- a/mysql-test/r/type_bit.result	2009-10-08 15:36:36 +0000
+++ b/mysql-test/r/type_bit.result	2010-02-11 09:57:10 +0000
@@ -785,4 +785,16 @@ t1	CREATE TABLE `t1` (
   KEY `a` (`a`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
+CREATE TABLE t1(a INT, b BIT(7) NOT NULL);
+INSERT INTO t1 VALUES (NULL, 0),(NULL, 0);
+SELECT SUM(a) FROM t1 group by b, a;
+SUM(a)
+NULL
+DROP TABLE t1;
+CREATE TABLE t1(a INT, b BIT(7) NOT NULL, c BIT(8) NOT NULL);
+INSERT INTO t1 VALUES (NULL, 0, 0),(NULL, 0, 0);
+SELECT SUM(a) FROM t1 group by c, b, a;
+SUM(a)
+NULL
+DROP TABLE t1;
 End of 5.1 tests

=== modified file 'mysql-test/t/type_bit.test'
--- a/mysql-test/t/type_bit.test	2009-10-08 15:36:36 +0000
+++ b/mysql-test/t/type_bit.test	2010-02-11 09:57:10 +0000
@@ -425,4 +425,17 @@ select hex(a) from t1;
 show create table t1;
 drop table t1;
 
+#
+# Bug#50591 bit(31) causes Duplicate entry '1-NULL' for key 'group_key'
+#
+CREATE TABLE t1(a INT, b BIT(7) NOT NULL);
+INSERT INTO t1 VALUES (NULL, 0),(NULL, 0);
+SELECT SUM(a) FROM t1 group by b, a;
+DROP TABLE t1;
+
+CREATE TABLE t1(a INT, b BIT(7) NOT NULL, c BIT(8) NOT NULL);
+INSERT INTO t1 VALUES (NULL, 0, 0),(NULL, 0, 0);
+SELECT SUM(a) FROM t1 group by c, b, a;
+DROP TABLE t1;
+
 --echo End of 5.1 tests

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-02-06 19:54:30 +0000
+++ b/sql/sql_select.cc	2010-02-11 09:57:10 +0000
@@ -9832,7 +9832,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
   KEY_PART_INFO *key_part_info;
   Item **copy_func;
   MI_COLUMNDEF *recinfo;
-  uint total_uneven_bit_length= 0;
+  uint total_uneven_bit_length= 0, hidden_uneven_bit_length= 0;
   bool force_copy_fields= param->force_copy_fields;
   /* Treat sum functions as normal ones when loose index scan is used. */
   save_sum_fields|= param->precomputed_group_by;
@@ -10109,6 +10109,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
       */
       param->hidden_field_count= fieldnr;
       null_count= 0;
+      hidden_uneven_bit_length= total_uneven_bit_length;
+      total_uneven_bit_length= 0;
     }
   }
   DBUG_ASSERT(fieldnr == (uint) (reg_field - table->field));
@@ -10154,7 +10156,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
     else
       null_count++;
   }
-  hidden_null_pack_length=(hidden_null_count+7)/8;
+  hidden_null_pack_length= (hidden_null_count + 7 +
+                            hidden_uneven_bit_length) / 8;
   null_pack_length= (hidden_null_pack_length +
                      (null_count + total_uneven_bit_length + 7) / 8);
   reclength+=null_pack_length;


Attachment: [text/bzr-bundle] bzr/sergey.glukhov@sun.com-20100211095710-46lr7oqsxzqoothe.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:3372)Bug#50591Sergey Glukhov11 Feb
  • Re: bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:3372)Bug#50591Sergey Vojtovich11 Feb
  • Re: bzr commit into mysql-5.1-bugteam branch (Sergey.Glukhov:3372)Bug#50591Ramil Kalimullin <ramil@sun.com>12 Feb