Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new lock syntax in MySQL8 #66

Merged
merged 1 commit into from
Aug 11, 2023

Conversation

patrickcarnahan
Copy link

@patrickcarnahan patrickcarnahan commented Aug 7, 2023

Description

This completes the work to enable the following syntax in vitess:

  • SELECT .. FOR SHARE (NOWAIT|SKIP LOCKED)
  • SELECT .. FOR UPDATE (NOWAIT|SKIP LOCKED)

The aim is to finish the work started in vitessio#5336, which added the keywords to the syntax but didn't modify the ast and other functions to handle it.

Related Issue(s)

Fixes vitessio#5249

Checklist

  • "Backport to:" labels have been added if this change should be back-ported
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on the CI
  • Documentation was added or is not required

Deployment Notes

Signed-off-by: Patrick Carnahan <patrickcarnahan@github.com>
@patrickcarnahan patrickcarnahan force-pushed the patrickcarnahan/mysql8-lock-syntax branch from 46eb82b to bc06477 Compare August 7, 2023 20:35
Copy link
Author

@patrickcarnahan patrickcarnahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i also found query_tests.go under go/vt/vttablet/endtoend/queries_test.go which i can add to but wasn't sure if that is relevant for this type of change.

@@ -1004,7 +1004,7 @@ INPUT
SELECT 1 FOR SHARE UNION SELECT 2;
END
ERROR
syntax error at position 19 near 'SHARE'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this actually matches the error mysql8 provides when issuing the same query via explain:

mysql> explain select 1 for share union select 2;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'union select 2' at line 1

@@ -6868,6 +6868,26 @@ FOR UPDATE
{
$$ = ForUpdateLock
}
| FOR UPDATE NOWAIT
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if there is a "better" way to do this, but i saw this type of pattern elsewhere so seemed to make sense.

@patrickcarnahan patrickcarnahan marked this pull request as ready for review August 7, 2023 20:38
@arthurschreiber
Copy link
Member

I'm going to merge this as we tested this out and it was working as expected. 👍

@arthurschreiber arthurschreiber merged commit 6b8851d into master Aug 11, 2023
221 of 228 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for SKIP LOCKED and NOWAIT
2 participants