Bug #37721 | ORDER BY when WHERE contains non-partitioned index column | ||
---|---|---|---|
Submitted: | 28 Jun 2008 16:57 | Modified: | 10 Nov 2008 15:18 |
Reporter: | duke hound | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Partitions | Severity: | S3 (Non-critical) |
Version: | 5.1,6.0.4-alpha,6.0 BZR | OS: | Any (Linux, MS Windows xp pro 2002 sp3 AMD athlon 2600+ 2.13ghz 480 MB ram) |
Assigned to: | Mattias Jonsson | CPU Architecture: | Any |
Tags: | non-partitioned index, order by, sort, where |
[28 Jun 2008 16:57]
duke hound
[28 Jun 2008 17:40]
Sveta Smirnova
Thank you for the report. Verified as described. Bug is not repeatable if use MyISAM storage engine.
[5 Aug 2008 14:54]
Konstantin Osipov
Setting risk/effort, and the right lead, since the bug seems to be in the optimizer.
[16 Sep 2008 13:02]
Joe Grasse
Same thing happens with the range partition type. Also, curious if this will be fixed before the GA of 5.1?
[30 Sep 2008 12:16]
Mattias Jonsson
This is probably due to key_rec_cmp does only sort for the given index, but for clustered primary key it should also on second level (if key for given index is equal) sort by primary key.
[3 Oct 2008 18:26]
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/55287 2751 Mattias Jonsson 2008-10-03 Bug#37721: ORDER BY when WHERE contains non-partitioned index column There was actually two problems 1) when clustered pk, order by non pk index should also compare with pk as last resort to differ keys from each other 2) bug in the index search handling in ha_partition (was found when extending the test case Solution to 1 was to include the pk in key compare if clustered pk and search on other index. 2 was just a faulty compare of key_length.
[3 Oct 2008 18:30]
Mattias Jonsson
I also fixed the following bug in the patch (faulty key_length compare): CREATE TABLE t1 ( a INT, b INT, PRIMARY KEY (a), INDEX (b)) ENGINE InnoDB PARTITION BY HASH(a) PARTITIONS 3; INSERT INTO t1 VALUES (0,0),(4,0),(2,0); SELECT a FROM t1 WHERE b = 0 ORDER BY a ASC; a 0 4 2
[10 Oct 2008 17:06]
Mattias Jonsson
New proposed patch, incl. comments, the commit mail got lost...
Attachment: b37721.patch.tar.gz (application/x-gzip, text), 4.91 KiB.
[30 Oct 2008 8:12]
Mattias Jonsson
Pushed into 6.0-bugteam and 5.1-bugteam
[10 Nov 2008 10:54]
Bugs System
Pushed into 6.0.8-alpha (revid:mattias.jonsson@sun.com-20081010100101-cahpb979obu0pr2y) (version source revid:mattias.jonsson@sun.com-20081029223410-bm7llueahyz96nj0) (pib:5)
[10 Nov 2008 11:37]
Bugs System
Pushed into 5.1.30 (revid:mattias.jonsson@sun.com-20081010100101-cahpb979obu0pr2y) (version source revid:mattias.jonsson@sun.com-20081029220141-coyup0ey28z66pxn) (pib:5)
[10 Nov 2008 15:18]
Jon Stephens
Documented bugfix in the 5.1.30 and 6.0.8 changelogs as follows: When executing an ORDER BY query on a partitioned InnoDB table using an index that was not in the partition expression, the results were sorted on a per-partition basis rather than for the table as a whole.
[10 Nov 2008 15:20]
Jon Stephens
5.1 fix will appear in 5.1.31 per mail from Joro. Adjusted changelog entry accordingly.
[19 Jan 2009 11:26]
Bugs System
Pushed into 5.1.31-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090119095303-uwwvxiibtr38djii) (version source revid:tomas.ulin@sun.com-20090108105244-8opp3i85jw0uj5ib) (merge vers: 5.1.31-ndb-6.2.17) (pib:6)
[19 Jan 2009 13:04]
Bugs System
Pushed into 5.1.31-ndb-6.3.21 (revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (version source revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (merge vers: 5.1.31-ndb-6.3.21) (pib:6)
[19 Jan 2009 16:10]
Bugs System
Pushed into 5.1.31-ndb-6.4.1 (revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (version source revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (merge vers: 5.1.31-ndb-6.4.1) (pib:6)