Bug #15393 range partitioning puts records in the wrong partition
Submitted: 1 Dec 2005 16:25 Modified: 2 Feb 2006 14:09
Reporter: Andy Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Partitions Severity:S2 (Serious)
Version:mysql-5.1.4-alpha OS:Linux (linux)
Assigned to: Sergei Glukhov CPU Architecture:Any

[1 Dec 2005 16:25] Andy
Description:
Using range partitioning with a case statement as the partition function puts records in the wrong partition.  i.e If you have partitions a,b, and c and try to insert a record that should go into c it goes into b instead.

How to repeat:
CREATE TABLE partition_test (
  a varchar(1) default NULL     
) ENGINE=MyISAM DEFAULT CHARSET=latin1 
PARTITION BY RANGE(CASE a WHEN 'a' THEN 1
WHEN 'b' THEN 2
WHEN 'c' THEN 3
END) 
(
PARTITION a VALUES LESS THAN (2),
PARTITION b VALUES LESS THAN (3),
PARTITION c VALUES LESS THAN (4)
);

Then

INSERT INTO partition_test(a) values ('c');

record will go into partition b (partition_test_b.MYD file) instead of the expected partition c.

Suggested fix:
Fix so partitioning works as expected.
[20 Dec 2005 10:05] 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:

  http://lists.mysql.com/commits/273
[2 Feb 2006 14:05] Jon Stephens
Need 3-part version number for documentation.

Updated Category to Server:Partitioning.
[2 Feb 2006 14:09] Jon Stephens
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Disregard previous comment concerning version number. 

Documented in 5.1.6 changelog. Closed.