[MDEV-3805] Wrong order in result with ordered subquery and derived_merge = off Created: 2012-10-10 Updated: 2012-12-10 Resolved: 2012-12-10 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 5.5.27 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Tom Jansen | Assignee: | Unassigned |
| Resolution: | Not a Bug | Votes: | 1 |
| Labels: | None | ||
| Environment: |
mysqld Ver 5.5.27-MariaDB-mariadb1~squeeze-log for debian-linux-gnu on x86_64 (mariadb.org binary distribution) Debian 6.0, amd64, cleanly installed VM default debian config for mariaDB except for bind-address, which was changed to local network. |
||
| Description |
|
Reproduced on three different machines all running Maria 5.5.27.
The very weird part is that removing some of the columns of the bugdata table removes the problem. InnoDB, MyISAM or Aria for the bugdata table does not make a difference. Reproducable on my systems by running the SQL below (Jira does not seems to like the attachment)
|
| Comments |
| Comment by Tom Jansen [ 2012-10-24 ] | |||||||||||||||||||||
|
Also reproducable on mysqld Ver 5.5.28-MariaDB-mariadb1~squeeze for debian-linux-gnu on x86_64 (mariadb.org binary distribution) | |||||||||||||||||||||
| Comment by Elena Stepanova [ 2012-10-24 ] | |||||||||||||||||||||
|
Hi Tom, Could you please point at any documentation that makes you think that the result should be sorted? Basically, we are talking about a query similar, if not identical, to what one would expect while selecting from a table with pre-ordered records, but not using ORDER BY while doing so, right? Would you agree that in this case the order of the result set is, in general, unpredictable? From the practical point of view, is there any reason why you need to have ORDER BY in the subquery rather than outside? | |||||||||||||||||||||
| Comment by Tom Jansen [ 2012-10-24 ] | |||||||||||||||||||||
|
Hi Elena, First of all, thanks for contacting! I can not find any documentation about whether the result should be sorted or not. Secondly, if not specifying any order, I'd have to agree with you that order is unpredictable.
The last row is not expected in this case. While in this example, the order by could have been done by the outer query, this does not work when using more complex inner queries that are sorted on aggregated fields. I can imagine that you believe that this is abuse of MariaDB and not a bug. It used to work though ... Thanks for your time. | |||||||||||||||||||||
| Comment by Elena Stepanova [ 2012-10-24 ] | |||||||||||||||||||||
|
Hi Tom, I don't think it's abuse of MariaDB, I just think that relying on non-deterministic behavior is always dangerous in a long run, and the example you provided proves the point. It used to work by chance, then some other optimization was implemented or changed, and it started working differently – that's how it happens. | |||||||||||||||||||||
| Comment by Elena Stepanova [ 2012-12-10 ] | |||||||||||||||||||||
|
Yet another confirmation by Sergei Golubchik in I've added his reply to the KB: https://kb.askmonty.org/en/why-is-order-by-in-a-from-subquery-ignored/ |