Detect if a system variable scope was explicitly specified or not#302
Merged
Detect if a system variable scope was explicitly specified or not#302
Conversation
… explicitly specified, or if one has been inferred.
1b506b1 to
43038f0
Compare
zachmu
approved these changes
Jan 17, 2024
go/vt/sqlparser/ast.go
Outdated
| // specify a variable (returns SetScope_None), then it is recommended to use the original non-broken string, as this | ||
| // will always only return the last part. `[]string{"my_db", "my_tbl", "my_col"}` will return "my_col" with SetScope_None. | ||
| func VarScope(nameParts ...string) (string, SetScope, error) { | ||
| func VarScope(nameParts ...string) (string, SetScope, bool, error) { |
Member
There was a problem hiding this comment.
Maybe a little cleaner to add this as a new field on SetScope rather than as a bool here
Author
There was a problem hiding this comment.
Good idea. SetScope is currently just an alias for a string, so we'd need to turn it into a struct. Might not be worth it right this minute, but I'll take a closer look.
…pe, so that we can match the exact specified casing in the field metadata for the result set
This was referenced Jan 18, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes the
VarScopefunction so that it returns whether a scope was explicitly specified, or if one has been inferred.This is needed because some tooling (e.g. the official MySQL .NET Connector library) will query system variables (e.g.
SELECT @@max_allowed_packet) and then will look up the returned value in the result set using the expected column name (@@max_allowed_packet). Currently, from the way we parse the system variable, this was always returned with the scope present, but to match MySQL's behavior, the column name needs to match the requested name.Related GMS PR: dolthub/go-mysql-server#2266