@@ -1819,6 +1819,15 @@ impl<'a> Parser<'a> {
1819
1819
})
1820
1820
}
1821
1821
1822
+ fn keyword_to_modifier(k: Option<Keyword>) -> ContextModifier {
1823
+ match k {
1824
+ Some(Keyword::LOCAL) => ContextModifier::Local,
1825
+ Some(Keyword::GLOBAL) => ContextModifier::Global,
1826
+ Some(Keyword::SESSION) => ContextModifier::Session,
1827
+ _ => ContextModifier::None,
1828
+ }
1829
+ }
1830
+
1822
1831
/// Check if the root is an identifier and all fields are identifiers.
1823
1832
fn is_all_ident(root: &Expr, fields: &[AccessExpr]) -> bool {
1824
1833
if !matches!(root, Expr::Identifier(_)) {
@@ -11138,11 +11147,7 @@ impl<'a> Parser<'a> {
11138
11147
/// Parse a `SET ROLE` statement. Expects SET to be consumed already.
11139
11148
fn parse_set_role(&mut self, modifier: Option<Keyword>) -> Result<Statement, ParserError> {
11140
11149
self.expect_keyword_is(Keyword::ROLE)?;
11141
- let context_modifier = match modifier {
11142
- Some(Keyword::LOCAL) => ContextModifier::Local,
11143
- Some(Keyword::SESSION) => ContextModifier::Session,
11144
- _ => ContextModifier::None,
11145
- };
11150
+ let context_modifier = Self::keyword_to_modifier(modifier);
11146
11151
11147
11152
let role_name = if self.parse_keyword(Keyword::NONE) {
11148
11153
None
@@ -11214,8 +11219,12 @@ impl<'a> Parser<'a> {
11214
11219
}
11215
11220
11216
11221
fn parse_set(&mut self) -> Result<Statement, ParserError> {
11217
- let modifier =
11218
- self.parse_one_of_keywords(&[Keyword::SESSION, Keyword::LOCAL, Keyword::HIVEVAR]);
11222
+ let modifier = self.parse_one_of_keywords(&[
11223
+ Keyword::SESSION,
11224
+ Keyword::LOCAL,
11225
+ Keyword::HIVEVAR,
11226
+ Keyword::GLOBAL,
11227
+ ]);
11219
11228
11220
11229
if let Some(Keyword::HIVEVAR) = modifier {
11221
11230
self.expect_token(&Token::Colon)?;
@@ -11231,7 +11240,7 @@ impl<'a> Parser<'a> {
11231
11240
{
11232
11241
if self.consume_token(&Token::Eq) || self.parse_keyword(Keyword::TO) {
11233
11242
return Ok(Set::SingleAssignment {
11234
- local: modifier == Some(Keyword::LOCAL ),
11243
+ scope: Self::keyword_to_modifier(modifier ),
11235
11244
hivevar: modifier == Some(Keyword::HIVEVAR),
11236
11245
variable: ObjectName::from(vec!["TIMEZONE".into()]),
11237
11246
values: self.parse_set_values(false)?,
@@ -11321,7 +11330,7 @@ impl<'a> Parser<'a> {
11321
11330
}?;
11322
11331
11323
11332
Ok(Set::SingleAssignment {
11324
- local: modifier == Some(Keyword::LOCAL ),
11333
+ scope: Self::keyword_to_modifier(modifier ),
11325
11334
hivevar: modifier == Some(Keyword::HIVEVAR),
11326
11335
variable,
11327
11336
values,
@@ -11349,7 +11358,7 @@ impl<'a> Parser<'a> {
11349
11358
if self.consume_token(&Token::Eq) || self.parse_keyword(Keyword::TO) {
11350
11359
let stmt = match variables {
11351
11360
OneOrManyWithParens::One(var) => Set::SingleAssignment {
11352
- local: modifier == Some(Keyword::LOCAL ),
11361
+ scope: Self::keyword_to_modifier(modifier ),
11353
11362
hivevar: modifier == Some(Keyword::HIVEVAR),
11354
11363
variable: var,
11355
11364
values: self.parse_set_values(false)?,
0 commit comments