Bug #96677 | "SELECT ... INTO var_name FOR UPDATE" not working in MySQL 8 | ||
---|---|---|---|
Submitted: | 28 Aug 2019 3:15 | Modified: | 3 Dec 2019 17:57 |
Reporter: | Vinodh Krish | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Parser | Severity: | S3 (Non-critical) |
Version: | 8.0, 8.0.11, 8.0.17 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | regression, SELECT, select into, variable |
[28 Aug 2019 3:15]
Vinodh Krish
[28 Aug 2019 3:38]
Vinodh Krish
Tested and confirmed the behaviour in MySQL Community 8.0.17 and Percona MySQL.
[28 Aug 2019 3:41]
Vinodh Krish
Sorry, Please note the change in suggested fix mentioned in initial report. The suggested fix should be the following query to work as mentioned in the document and 5.7: select id from t1 limit 1 into @id_var for update;
[28 Aug 2019 6:21]
MySQL Verification Team
Hello Vinodh, Thank you for the report. Observed that this behavior exists since 8.0.11. regards, Umesh
[29 Aug 2019 11:31]
Zsolt Parragi
A possible fix (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: bug96677.diff (application/octet-stream, text), 12.64 KiB.
[29 Aug 2019 11:34]
Zsolt Parragi
I added a patch which solves the mentioned issue, for all the queries I tested with. The root cause seems to be WL#8083 (or something even before it, I didn't check git blame further), where the refactoring assumed that INTO is the last clause in a select, there's even a long comment explaining this. As it's possible that somebody already relies on the new, undocumented order, my patch allows both versions.
[29 Aug 2019 11:57]
MySQL Verification Team
Thank you, Zsolt Parragi for the contribution. regards, Umesh
[3 Dec 2019 17:57]
Paul DuBois
Posted by developer: Fixed in 8.0.19. For SELECT statements, an INTO var_name clause prior to a locking clause is legal but the parser rejected it.