[MDEV-8913] Derived queries with same column names as final projection causes issues when using Order By Created: 2015-10-07 Updated: 2015-10-30 Resolved: 2015-10-30 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Subquery, Optimizer |
| Affects Version/s: | 10.0.21, 10.1.7, 5.3.13, 5.5, 10.0, 10.1 |
| Fix Version/s: | 10.0.23, 10.1.9 |
| Type: | Bug | Priority: | Major |
| Reporter: | Ryan Griffith | Assignee: | Oleksandr Byelkin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | derived, wrong_result | ||
| Attachments: |
|
| Sprint: | 10.0.22, 10.1.9-1 |
| Description |
| Comments |
| Comment by Elena Stepanova [ 2015-10-19 ] | ||||||||||||||||||||||||||||||||||
|
rgriffith, thanks for the report. Smaller test case:
Reproducible on MariaDB 5.3 and higher, and also on MySQL 5.7. | ||||||||||||||||||||||||||||||||||
| Comment by Ryan Griffith [ 2015-10-19 ] | ||||||||||||||||||||||||||||||||||
|
Hi Elena, Thank you for your comments. Unfortunately, I'm using an ORM (.Net - Entity Framework / MySQL Connector) which generates these statements. I do not have any control over the output. Additionally, the sole reason I moved to MariaDB is for better performance due of derived tables due to the significant use of them in the generated SQL from the Entity Framework / MySQL connector. Turning off derived_merge would invalidate the very reason I moved to MariaDB. I'm stuck at this point unless MariaDB is updated or the MySQL connector is updated to use different column names. | ||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2015-10-19 ] | ||||||||||||||||||||||||||||||||||
|
I see. Hopefully it will be fixed soon. I assume you are on 10.0 now? | ||||||||||||||||||||||||||||||||||
| Comment by Ryan Griffith [ 2015-10-19 ] | ||||||||||||||||||||||||||||||||||
|
I am on 10.1.7 right now. Thank you! | ||||||||||||||||||||||||||||||||||
| Comment by Ryan Griffith [ 2015-10-19 ] | ||||||||||||||||||||||||||||||||||
|
I am setup as a Oracle contributor. Given that this is exhibited in MySQL 5.7, should I report the bug there as well? | ||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2015-10-19 ] | ||||||||||||||||||||||||||||||||||
|
Sure, please do report it, it's our normal practice to inform upstream about bugs that affect MySQL as well, even though in case of optimizer bugs we rarely use upstream fixes. | ||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2015-10-20 ] | ||||||||||||||||||||||||||||||||||
|
The problem is that in the SELECT list we overwrite Item name according to AS clause but tablename is left as it was, so ORDER BY really thinks it resolve correctly (and it does according to new names) but of course it is wrong... | ||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2015-10-20 ] | ||||||||||||||||||||||||||||||||||
|
TODO: check VIEW and normal tables | ||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2015-10-27 ] | ||||||||||||||||||||||||||||||||||
|
It is perfectly repeatable
| ||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2015-10-27 ] | ||||||||||||||||||||||||||||||||||
|
5.7 has the same problem. | ||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2015-10-27 ] | ||||||||||||||||||||||||||||||||||
|
revision-id: 772f7914db4fc6b293e438ad1c09dac59a239c5a (mariadb-10.0.21-41-g772f791)
find_item_in_list() now recognize view fields like a fields even if they rever to an expression. — | ||||||||||||||||||||||||||||||||||
| Comment by Ryan Griffith [ 2015-10-27 ] | ||||||||||||||||||||||||||||||||||
|
Thank you very much for your work on this. Where can I see the commit? I checked Github but did not see a branch that seemed like it would be the one I should look at. I'm curious as to the fix. Thanks! | ||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2015-10-27 ] | ||||||||||||||||||||||||||||||||||
|
For now you can see it only in e-mail list ( http://lists.askmonty.org/pipermail/commits/2015-October/008536.html ). it will be pushed on github after code review. | ||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2015-10-29 ] | ||||||||||||||||||||||||||||||||||
|
As discussed on IRC Sanja will additionally check why this query does not return errors:
| ||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2015-10-29 ] | ||||||||||||||||||||||||||||||||||
|
revision-id: 34f126ee9b7da4f277da4ddd39d5d927c4bce9db (mariadb-10.0.21-41-g34f126e)
find_item_in_list() now recognize view fields like a fields even if they rever to an expression. — | ||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2015-10-30 ] | ||||||||||||||||||||||||||||||||||
|
This patch looks Ok to push: |