@@ -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(_)) {
@@ -11148,11 +11157,7 @@ impl<'a> Parser<'a> {
1114811157 /// Parse a `SET ROLE` statement. Expects SET to be consumed already.
1114911158 fn parse_set_role(&mut self, modifier: Option<Keyword>) -> Result<Statement, ParserError> {
1115011159 self.expect_keyword_is(Keyword::ROLE)?;
11151- let context_modifier = match modifier {
11152- Some(Keyword::LOCAL) => ContextModifier::Local,
11153- Some(Keyword::SESSION) => ContextModifier::Session,
11154- _ => ContextModifier::None,
11155- };
11160+ let context_modifier = Self::keyword_to_modifier(modifier);
1115611161
1115711162 let role_name = if self.parse_keyword(Keyword::NONE) {
1115811163 None
@@ -11224,8 +11229,12 @@ impl<'a> Parser<'a> {
1122411229 }
1122511230
1122611231 fn parse_set(&mut self) -> Result<Statement, ParserError> {
11227- let modifier =
11228- self.parse_one_of_keywords(&[Keyword::SESSION, Keyword::LOCAL, Keyword::HIVEVAR]);
11232+ let modifier = self.parse_one_of_keywords(&[
11233+ Keyword::SESSION,
11234+ Keyword::LOCAL,
11235+ Keyword::HIVEVAR,
11236+ Keyword::GLOBAL,
11237+ ]);
1122911238
1123011239 if let Some(Keyword::HIVEVAR) = modifier {
1123111240 self.expect_token(&Token::Colon)?;
@@ -11241,7 +11250,7 @@ impl<'a> Parser<'a> {
1124111250 {
1124211251 if self.consume_token(&Token::Eq) || self.parse_keyword(Keyword::TO) {
1124311252 return Ok(Set::SingleAssignment {
11244- local: modifier == Some(Keyword::LOCAL ),
11253+ scope: Self::keyword_to_modifier(modifier ),
1124511254 hivevar: modifier == Some(Keyword::HIVEVAR),
1124611255 variable: ObjectName::from(vec!["TIMEZONE".into()]),
1124711256 values: self.parse_set_values(false)?,
@@ -11331,7 +11340,7 @@ impl<'a> Parser<'a> {
1133111340 }?;
1133211341
1133311342 Ok(Set::SingleAssignment {
11334- local: modifier == Some(Keyword::LOCAL ),
11343+ scope: Self::keyword_to_modifier(modifier ),
1133511344 hivevar: modifier == Some(Keyword::HIVEVAR),
1133611345 variable,
1133711346 values,
@@ -11359,7 +11368,7 @@ impl<'a> Parser<'a> {
1135911368 if self.consume_token(&Token::Eq) || self.parse_keyword(Keyword::TO) {
1136011369 let stmt = match variables {
1136111370 OneOrManyWithParens::One(var) => Set::SingleAssignment {
11362- local: modifier == Some(Keyword::LOCAL ),
11371+ scope: Self::keyword_to_modifier(modifier ),
1136311372 hivevar: modifier == Some(Keyword::HIVEVAR),
1136411373 variable: var,
1136511374 values: self.parse_set_values(false)?,
0 commit comments