-
Notifications
You must be signed in to change notification settings - Fork 602
Parse SET GLOBAL variable modifier for MySQL #1696
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10533,8 +10533,17 @@ impl<'a> Parser<'a> { | |
} | ||
|
||
pub fn parse_set(&mut self) -> Result<Statement, ParserError> { | ||
let modifier = | ||
self.parse_one_of_keywords(&[Keyword::SESSION, Keyword::LOCAL, Keyword::HIVEVAR]); | ||
let modifier_keywords = if self.dialect.supports_global_variable_modifier() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking having the lone let scope = self.dialect.parse_set_variable_scope(self)?; |
||
&[ | ||
Keyword::SESSION, | ||
Keyword::LOCAL, | ||
Keyword::GLOBAL, | ||
Keyword::HIVEVAR, | ||
][..] | ||
} else { | ||
&[Keyword::SESSION, Keyword::LOCAL, Keyword::HIVEVAR][..] | ||
}; | ||
let modifier = self.parse_one_of_keywords(modifier_keywords); | ||
if let Some(Keyword::HIVEVAR) = modifier { | ||
self.expect_token(&Token::Colon)?; | ||
} else if let Some(set_role_stmt) = | ||
|
@@ -10605,8 +10614,14 @@ impl<'a> Parser<'a> { | |
if parenthesized_assignment { | ||
self.expect_token(&Token::RParen)?; | ||
} | ||
let scope = match modifier { | ||
Some(Keyword::LOCAL) => SetVariableScope::Local, | ||
Some(Keyword::GLOBAL) => SetVariableScope::Global, | ||
Some(Keyword::SESSION) => SetVariableScope::Session, | ||
_ => SetVariableScope::None, | ||
}; | ||
return Ok(Statement::SetVariable { | ||
local: modifier == Some(Keyword::LOCAL), | ||
scope, | ||
hivevar: Some(Keyword::HIVEVAR) == modifier, | ||
variables, | ||
value: values, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it work the same to define scope as an optional field (
scope: Option<SetVariableScope>
)? in order to representNone
by convention?