@@ -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(_)) {
@@ -11148,11 +11157,7 @@ impl<'a> Parser<'a> {
11148
11157
/// Parse a `SET ROLE` statement. Expects SET to be consumed already.
11149
11158
fn parse_set_role(&mut self, modifier: Option<Keyword>) -> Result<Statement, ParserError> {
11150
11159
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);
11156
11161
11157
11162
let role_name = if self.parse_keyword(Keyword::NONE) {
11158
11163
None
@@ -11224,8 +11229,12 @@ impl<'a> Parser<'a> {
11224
11229
}
11225
11230
11226
11231
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
+ ]);
11229
11238
11230
11239
if let Some(Keyword::HIVEVAR) = modifier {
11231
11240
self.expect_token(&Token::Colon)?;
@@ -11241,7 +11250,7 @@ impl<'a> Parser<'a> {
11241
11250
{
11242
11251
if self.consume_token(&Token::Eq) || self.parse_keyword(Keyword::TO) {
11243
11252
return Ok(Set::SingleAssignment {
11244
- local: modifier == Some(Keyword::LOCAL ),
11253
+ scope: Self::keyword_to_modifier(modifier ),
11245
11254
hivevar: modifier == Some(Keyword::HIVEVAR),
11246
11255
variable: ObjectName::from(vec!["TIMEZONE".into()]),
11247
11256
values: self.parse_set_values(false)?,
@@ -11331,7 +11340,7 @@ impl<'a> Parser<'a> {
11331
11340
}?;
11332
11341
11333
11342
Ok(Set::SingleAssignment {
11334
- local: modifier == Some(Keyword::LOCAL ),
11343
+ scope: Self::keyword_to_modifier(modifier ),
11335
11344
hivevar: modifier == Some(Keyword::HIVEVAR),
11336
11345
variable,
11337
11346
values,
@@ -11359,7 +11368,7 @@ impl<'a> Parser<'a> {
11359
11368
if self.consume_token(&Token::Eq) || self.parse_keyword(Keyword::TO) {
11360
11369
let stmt = match variables {
11361
11370
OneOrManyWithParens::One(var) => Set::SingleAssignment {
11362
- local: modifier == Some(Keyword::LOCAL ),
11371
+ scope: Self::keyword_to_modifier(modifier ),
11363
11372
hivevar: modifier == Some(Keyword::HIVEVAR),
11364
11373
variable: var,
11365
11374
values: self.parse_set_values(false)?,
0 commit comments