List:Commits« Previous MessageNext Message »
From:mattiasj Date:February 7 2008 2:10pm
Subject:bk commit into 5.1 tree (mattiasj:1.2518) BUG#34358
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mattiasj.  When mattiasj does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-02-07 15:09:59+01:00, mattiasj@stripped +3 -0
  Bug#34358: Cannot find specified bit row in partitioned table
  
  Problem was incorrect data length in the key_restore function
  resulting in overwriting the search key.
  
  Solution, remove one byte in length if uneven bits are used.

  mysql-test/r/partition_datatype.result@stripped, 2008-02-07 15:09:56+01:00, mattiasj@stripped +49 -19
    Bug#34358: Cannot find specified bit row
    
    Updated result file

  mysql-test/t/partition_datatype.test@stripped, 2008-02-07 15:09:57+01:00, mattiasj@stripped +29 -13
    Bug#34358: Cannot find specified bit row
    
    Updated test file
    (corrected a few errors and added a test case for the bug)

  sql/key.cc@stripped, 2008-02-07 15:09:57+01:00, mattiasj@stripped +6 -1
    Bug34358: error in key_restore for bit fields with uneven bits
    
    When uneven bits exist, it has special treatment for the uneven bits
    but does use the same byte again when copying the rest of
    the key_part.

diff -Nrup a/mysql-test/r/partition_datatype.result b/mysql-test/r/partition_datatype.result
--- a/mysql-test/r/partition_datatype.result	2007-11-12 14:51:12 +01:00
+++ b/mysql-test/r/partition_datatype.result	2008-02-07 15:09:56 +01:00
@@ -30,22 +30,22 @@ a
 2
 drop table t1;
 create table t1 (a float not null) partition by key (a);
-insert into t1 values (2.1);
-select * from t1 where a = 2.1;
+insert into t1 values (0.5);
+select * from t1 where a = 0.5;
 a
+0.5
 drop table t1;
 create table t1 (a double not null) partition by key (a);
-insert into t1 values (2.1);
-select * from t1 where a = 2.1;
+insert into t1 values (0.5);
+select * from t1 where a = 0.5;
 a
-2.1
+0.5
 drop table t1;
-create table t1 (a decimal not null) partition by key (a);
+create table t1 (a decimal(4,2) not null) partition by key (a);
 insert into t1 values (2.1);
-Warnings:
-Note	1265	Data truncated for column 'a' at row 1
 select * from t1 where a = 2.1;
 a
+2.10
 drop table t1;
 create table t1 (a date not null) partition by key (a);
 insert into t1 values ('2001-01-01');
@@ -156,22 +156,22 @@ a
 2
 drop table t1;
 create table t1 (a float) partition by key (a);
-insert into t1 values (2.1);
-select * from t1 where a = 2.1;
+insert into t1 values (0.5);
+select * from t1 where a = 0.5;
 a
+0.5
 drop table t1;
 create table t1 (a double) partition by key (a);
-insert into t1 values (2.1);
-select * from t1 where a = 2.1;
+insert into t1 values (0.5);
+select * from t1 where a = 0.5;
 a
-2.1
+0.5
 drop table t1;
-create table t1 (a decimal) partition by key (a);
+create table t1 (a decimal(4,2)) partition by key (a);
 insert into t1 values (2.1);
-Warnings:
-Note	1265	Data truncated for column 'a' at row 1
 select * from t1 where a = 2.1;
 a
+2.10
 drop table t1;
 create table t1 (a date) partition by key (a);
 insert into t1 values ('2001-01-01');
@@ -254,25 +254,41 @@ drop table t1;
 create table t1 (a varchar(65531)) partition by key (a);
 insert into t1 values ('bbbb');
 insert into t1 values ('aaaa');
-select * from t1 where a = 'aaa%';
+select * from t1 where a = 'aaaa';
 a
+aaaa
 select * from t1 where a like 'aaa%';
 a
 aaaa
+select * from t1 where a = 'bbbb';
+a
+bbbb
 drop table t1;
 create table t1 (a varchar(65532)) partition by key (a);
 insert into t1 values ('bbbb');
 insert into t1 values ('aaaa');
-select * from t1 where a = 'aaa%';
+select * from t1 where a = 'aaaa';
 a
+aaaa
 select * from t1 where a like 'aaa%';
 a
 aaaa
+select * from t1 where a = 'bbbb';
+a
+bbbb
 drop table t1;
 create table t1 (a varchar(65533) not null) partition by key (a);
+insert into t1 values ('bbbb');
 insert into t1 values ('aaaa');
-select * from t1 where a = 'aaa%';
+select * from t1 where a = 'aaaa';
 a
+aaaa
+select * from t1 where a like 'aaa%';
+a
+aaaa
+select * from t1 where a = 'bbbb';
+a
+bbbb
 drop table t1;
 create table t1 (a varchar(65533)) partition by key (a);
 ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
@@ -280,3 +296,17 @@ create table t1 (a varchar(65534) not nu
 ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
 create table t1 (a varchar(65535)) partition by key (a);
 ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
+create table t1 (a bit(27), primary key (a)) engine=myisam
+partition by hash (a)
+(partition p0, partition p1, partition p2);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` bit(27) NOT NULL DEFAULT '\0\0\0\0',
+  PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION p0 ENGINE = MyISAM, PARTITION p1 ENGINE = MyISAM, PARTITION p2 ENGINE = MyISAM) */
+insert into t1 values (1),(4),(7),(10),(13),(16),(19),(22),(25),(28),(31),(34);
+select hex(a) from t1 where a = 7;
+hex(a)
+7
+drop table t1;
diff -Nrup a/mysql-test/t/partition_datatype.test b/mysql-test/t/partition_datatype.test
--- a/mysql-test/t/partition_datatype.test	2007-11-12 14:51:12 +01:00
+++ b/mysql-test/t/partition_datatype.test	2008-02-07 15:09:57 +01:00
@@ -37,14 +37,14 @@ insert into t1 values (2);
 select * from t1 where a = 2;
 drop table t1;
 create table t1 (a float not null) partition by key (a);
-insert into t1 values (2.1);
-select * from t1 where a = 2.1;
+insert into t1 values (0.5);
+select * from t1 where a = 0.5;
 drop table t1;
 create table t1 (a double not null) partition by key (a);
-insert into t1 values (2.1);
-select * from t1 where a = 2.1;
+insert into t1 values (0.5);
+select * from t1 where a = 0.5;
 drop table t1;
-create table t1 (a decimal not null) partition by key (a);
+create table t1 (a decimal(4,2) not null) partition by key (a);
 insert into t1 values (2.1);
 select * from t1 where a = 2.1;
 drop table t1;
@@ -126,14 +126,14 @@ insert into t1 values (2);
 select * from t1 where a = 2;
 drop table t1;
 create table t1 (a float) partition by key (a);
-insert into t1 values (2.1);
-select * from t1 where a = 2.1;
+insert into t1 values (0.5);
+select * from t1 where a = 0.5;
 drop table t1;
 create table t1 (a double) partition by key (a);
-insert into t1 values (2.1);
-select * from t1 where a = 2.1;
+insert into t1 values (0.5);
+select * from t1 where a = 0.5;
 drop table t1;
-create table t1 (a decimal) partition by key (a);
+create table t1 (a decimal(4,2)) partition by key (a);
 insert into t1 values (2.1);
 select * from t1 where a = 2.1;
 drop table t1;
@@ -192,18 +192,23 @@ drop table t1;
 create table t1 (a varchar(65531)) partition by key (a);
 insert into t1 values ('bbbb');
 insert into t1 values ('aaaa');
-select * from t1 where a = 'aaa%';
+select * from t1 where a = 'aaaa';
 select * from t1 where a like 'aaa%';
+select * from t1 where a = 'bbbb';
 drop table t1;
 create table t1 (a varchar(65532)) partition by key (a);
 insert into t1 values ('bbbb');
 insert into t1 values ('aaaa');
-select * from t1 where a = 'aaa%';
+select * from t1 where a = 'aaaa';
 select * from t1 where a like 'aaa%';
+select * from t1 where a = 'bbbb';
 drop table t1;
 create table t1 (a varchar(65533) not null) partition by key (a);
+insert into t1 values ('bbbb');
 insert into t1 values ('aaaa');
-select * from t1 where a = 'aaa%';
+select * from t1 where a = 'aaaa';
+select * from t1 where a like 'aaa%';
+select * from t1 where a = 'bbbb';
 drop table t1;
 -- error ER_TOO_BIG_ROWSIZE
 create table t1 (a varchar(65533)) partition by key (a);
@@ -211,3 +216,14 @@ create table t1 (a varchar(65533)) parti
 create table t1 (a varchar(65534) not null) partition by key (a);
 -- error ER_TOO_BIG_ROWSIZE
 create table t1 (a varchar(65535)) partition by key (a);
+
+#
+# Bug#34358: error in key_restore for bitfields with uneven bits
+#
+create table t1 (a bit(27), primary key (a)) engine=myisam
+partition by hash (a)
+(partition p0, partition p1, partition p2);
+show create table t1;
+insert into t1 values (1),(4),(7),(10),(13),(16),(19),(22),(25),(28),(31),(34);
+select hex(a) from t1 where a = 7;
+drop table t1;
diff -Nrup a/sql/key.cc b/sql/key.cc
--- a/sql/key.cc	2007-12-20 21:24:03 +01:00
+++ b/sql/key.cc	2008-02-07 15:09:57 +01:00
@@ -168,6 +168,7 @@ void key_restore(uchar *to_record, uchar
   }
   for (key_part= key_info->key_part ; (int) key_length > 0 ; key_part++)
   {
+    uchar used_uneven_bits= 0;
     if (key_part->null_bit)
     {
       if (*from_key++)
@@ -186,6 +187,8 @@ void key_restore(uchar *to_record, uchar
         set_rec_bits(bits, to_record + key_part->null_offset +
                      (key_part->null_bit == 128),
                      field->bit_ofs, field->bit_len);
+        /* we have now used the byte with 'uneven' bits */
+        used_uneven_bits= 1;
       }
     }
     if (key_part->key_part_flag & HA_BLOB_PART)
@@ -222,7 +225,9 @@ void key_restore(uchar *to_record, uchar
     else
     {
       length= min(key_length, key_part->length);
-      memcpy(to_record + key_part->offset, from_key, (size_t) length);
+      /* skip the byte with 'uneven' bits, if used */
+      memcpy(to_record + key_part->offset, from_key + used_uneven_bits
+             , (size_t) length - used_uneven_bits);
     }
     from_key+= length;
     key_length-= length;
Thread
bk commit into 5.1 tree (mattiasj:1.2518) BUG#34358mattiasj7 Feb