Bug #34358 Can not find specified bit type primary key value in partitioned myisam table
Submitted: 6 Feb 2008 18:40 Modified: 28 Mar 2008 9:30
Reporter: Mattias Jonsson Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Partitions Severity:S2 (Serious)
Version:5.1 OS:Any
Assigned to: Mattias Jonsson CPU Architecture:Any

[6 Feb 2008 18:40] Mattias Jonsson
When testing a patch for valgrind warning when using bit type as primary key, myisam and partitioning, I found a new bug:

In some cases a partitioned myisam primary key bit field is not found when queried. (it is found in the correct partition in pruning, but when it tries to find the row, it gets the wrong partition from the wrong value of the field somewere).

How to repeat:
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;
select a + 0 from t1 order by a;
explain partitions select a from t1 where a = 7;
drop table t1;
[7 Feb 2008 9:34] Mattias Jonsson
Think i found the problem, when 'uneven' bits are used, then the key_restore function copies one byte too much in the memcpy back to the record.
[7 Feb 2008 14:10] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:


ChangeSet@1.2518, 2008-02-07 15:09:59+01:00, mattiasj@witty.ndb.mysql.com +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.
[7 Feb 2008 18:47] Mattias Jonsson
Pushed into mysql-6.0-engines and mysql-5.1-engines
[27 Mar 2008 11:18] Bugs System
Pushed into 5.1.24-rc
[27 Mar 2008 17:50] Bugs System
Pushed into 6.0.5-alpha
[28 Mar 2008 9:30] Jon Stephens
Documented as follows in the 5.1.24 and 6.0.5 changelogs:

        In some cases, matching rows from a partitioned MyISAM
        using a BIT column as the primary key were not found by queries.
[2 Apr 2008 19:45] Jon Stephens
Also noted in the 5.1.23-ndb-6.3.11 changelog.