[MDEV-8776] Update with subquery from the same table while derived_merge=on produces wrong result Created: 2015-09-09 Updated: 2017-04-24 Resolved: 2017-04-24 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Update, Optimizer |
| Affects Version/s: | 5.5, 10.0, 10.1 |
| Fix Version/s: | 5.5.47, 10.0.23, 10.1.9 |
| Type: | Bug | Priority: | Major |
| Reporter: | Ender Wiggin | Assignee: | Oleksandr Byelkin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
One master / one slave configuration with parallel replication. |
||
| Attachments: |
|
| Sprint: | 10.1.23 |
| Description |
|
After switching to MariaDB from MySQL, we noticed an update having different result. Test case:
Now execute the update:
Resulting table:
However, with derived_merge=off:
Resulting table:
This is also how it was before migrating from MySQL. |
| Comments |
| Comment by Elena Stepanova [ 2015-09-10 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the report and the test case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marc [ 2016-09-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi, Regards, Marc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2016-09-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
When the but be fixed status will be changed on the "closed". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marc [ 2016-09-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I have included the file derived_tables_bug_test_case.sql which shows the issue we have. The update statement does not use order by clause in our case. Marc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2016-09-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you a lot! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marc [ 2016-09-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
HI Oleksandr, thank you for your reply. Our test case seems to work fine in 10.1.13. Can you confirm it has been fixed in 10.1.13? Marc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2016-09-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I would be happy to say something, but the truth is that I have not looked on the problem close yet, so can say nothing. It is quite possible that problem also was shown in other bug and have foxed already. Wait a bit I'll check last tree of 5.5 if it is repeatable there (also possible that 10.1 is the version where it is fixed, then when time comes we will find and backport the fix). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2016-09-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original test suite is not repeatable any more. What you expected from SQL you uploaded, for me following looks correctt: select * from test_table; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marc [ 2016-09-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
And you tested in which version(s)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2016-09-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Current tree branch (no version yet) of 5.5. Will be in the next version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marc [ 2016-09-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Ok, so we can assume it has been fixed in 10.1.13 ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2016-09-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I do not know. It will take too much time for me to check certain version now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-04-19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Now it do not depend on temporary table or not, but result is differ from SELECT:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2017-04-24 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Above is wrong (sorry). And there is no difference in merge/materialize derived tables as deep as allow me my compmiler: mariadb-5.5.49 (older version can not be compiled with modern gcc). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-04-24 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The problem disappeared from 5.5 tree after this commit:
It was released with 5.5.47, 10.0.23 and 10.1.9. |