[MDEV-5424] SELECT using ORDER BY DESC and LIMIT produces unexpected results (InnoDB/XtraDB) Created: 2013-12-09 Updated: 2014-01-29 Resolved: 2014-01-02 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 5.5.33a, 5.5.34, 10.0.6 |
| Fix Version/s: | 5.5.35, 10.0.8 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Mikko Granqvist | Assignee: | Michael Widenius |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Debian Linux x86_64 |
||
| Description |
|
SELECT using ORDER BY DESC and LIMIT with suitably selected table (Note: This may be related to (or even duplicate of?) Reproduced on: Linux ***** 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux Reproducible at least on MariaDB versions: 5.5.34, 5.5.33a, 5.5.32, Was NOT able to reproduce (using this test setup at least) on MariaDB Was not able to reproduce this using MyISAM engine. Reproducible on MySQL: unknown (so no bug filed for MySQL yet) Test case to reproduce and results: 1) Used test case cat mysql-test/t/select_order_by_desc_limit_problem.test
2) First expected/correct results on MariaDB 5.5.28a
3) Then unexpected InnoDB results on MariaDB 5.5.29 (and later):
|
| Comments |
| Comment by Elena Stepanova [ 2013-12-10 ] |
|
Thanks for the perfect test case. Reproducible as described. The problem was introduced in 5.5 tree with the following revision: ------------------------------------------------------------ The previous fix for ------------------------------------------------------------ |
| Comment by Michael Widenius [ 2014-01-02 ] |
|
Problem was a wrong test if we should use extended keys or not. |
| Comment by Michael Widenius [ 2014-01-02 ] |
|
While fixing this, I noticed that the bug had a side effect that some queries was using extended keys even if they should not. The effect was that queries that used an order by on a repetition of the primary key, when all the used key parts where constant where optimized to use the key ... WHERE secondary_key=1 ORDER BY pk,pk; After my fix, this was not the case anymore. To get things to work as before, I added removal of duplicated elements in ORDER BY. ORDER BY a,b,a,b -> ORDER BY a,b This is similar to what is in MySQL 5.6, except that we can remove any kind of expression. |
| Comment by Daniel Bartholomew [ 2014-01-29 ] |
|
http://bazaar.launchpad.net/~maria-captains/maria/5.5/revision/4010 |