@@ -1819,6 +1819,15 @@ impl<'a> Parser<'a> {
18191819 })
18201820 }
18211821
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+
18221831 /// Check if the root is an identifier and all fields are identifiers.
18231832 fn is_all_ident(root: &Expr, fields: &[AccessExpr]) -> bool {
18241833 if !matches!(root, Expr::Identifier(_)) {
@@ -11138,11 +11147,7 @@ impl<'a> Parser<'a> {
1113811147 /// Parse a `SET ROLE` statement. Expects SET to be consumed already.
1113911148 fn parse_set_role(&mut self, modifier: Option<Keyword>) -> Result<Statement, ParserError> {
1114011149 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);
1114611151
1114711152 let role_name = if self.parse_keyword(Keyword::NONE) {
1114811153 None
@@ -11214,8 +11219,12 @@ impl<'a> Parser<'a> {
1121411219 }
1121511220
1121611221 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+ ]);
1121911228
1122011229 if let Some(Keyword::HIVEVAR) = modifier {
1122111230 self.expect_token(&Token::Colon)?;
@@ -11231,7 +11240,7 @@ impl<'a> Parser<'a> {
1123111240 {
1123211241 if self.consume_token(&Token::Eq) || self.parse_keyword(Keyword::TO) {
1123311242 return Ok(Set::SingleAssignment {
11234- local: modifier == Some(Keyword::LOCAL ),
11243+ scope: Self::keyword_to_modifier(modifier ),
1123511244 hivevar: modifier == Some(Keyword::HIVEVAR),
1123611245 variable: ObjectName::from(vec!["TIMEZONE".into()]),
1123711246 values: self.parse_set_values(false)?,
@@ -11321,7 +11330,7 @@ impl<'a> Parser<'a> {
1132111330 }?;
1132211331
1132311332 Ok(Set::SingleAssignment {
11324- local: modifier == Some(Keyword::LOCAL ),
11333+ scope: Self::keyword_to_modifier(modifier ),
1132511334 hivevar: modifier == Some(Keyword::HIVEVAR),
1132611335 variable,
1132711336 values,
@@ -11349,7 +11358,7 @@ impl<'a> Parser<'a> {
1134911358 if self.consume_token(&Token::Eq) || self.parse_keyword(Keyword::TO) {
1135011359 let stmt = match variables {
1135111360 OneOrManyWithParens::One(var) => Set::SingleAssignment {
11352- local: modifier == Some(Keyword::LOCAL ),
11361+ scope: Self::keyword_to_modifier(modifier ),
1135311362 hivevar: modifier == Some(Keyword::HIVEVAR),
1135411363 variable: var,
1135511364 values: self.parse_set_values(false)?,
0 commit comments