[MDEV-7626] incorrect result order when reusing aliases Created: 2015-02-24 Updated: 2017-05-23 Resolved: 2017-05-23 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Parser |
| Affects Version/s: | 5.5, 10.0, 10.1 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Hans Wurst | Assignee: | Oleksandr Byelkin |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | verified | ||
| Issue Links: |
|
||||||||
| Sprint: | 10.1.24 | ||||||||
| Description |
|
When executing in MySQL the result is sorted correctly at random. In MariaDB the result is incorrectly sorted alphabetically by name. When renaming the first alias (`SubQuery`.`Static` AS `Random`) to `Random2`, the sorting is correct in MariaDB, too. |
| Comments |
| Comment by Elena Stepanova [ 2015-02-25 ] | ||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the report. As a workaround, you can try setting optimizer_switch=derived_merge=off. | ||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-05-19 ] | ||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-05-22 ] | ||||||||||||||||||||||||||||||||||||||||||
|
I think it is not a bug. 1) ORDER BY actually should use references on result column names. So IMHO in MySQL is just unfixed bug. Use explicit expression in the ORDER BY if you want like: ORDER BY rand(), name | ||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-05-22 ] | ||||||||||||||||||||||||||||||||||||||||||
|
In fact, this behavior was changed in scope of
On the other hand, MySQL 5.7 now sorts by name. So, if it was an unfixed bug in MySQL and correct result in MariaDB, it's vice versa now, and you'll have to re-fix it.
| ||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-05-23 ] | ||||||||||||||||||||||||||||||||||||||||||
|
I think it should be other MDEV. |