@@ -9400,27 +9400,35 @@ impl<'a> Parser<'a> {
9400
9400
}
9401
9401
}
9402
9402
9403
+ /// Parse a `SET ROLE` statement. Expects SET to be consumed already.
9404
+ fn parse_set_role ( & mut self , modifier : Option < Keyword > ) -> Result < Statement , ParserError > {
9405
+ self . expect_keyword ( Keyword :: ROLE ) ?;
9406
+ let context_modifier = match modifier {
9407
+ Some ( Keyword :: LOCAL ) => ContextModifier :: Local ,
9408
+ Some ( Keyword :: SESSION ) => ContextModifier :: Session ,
9409
+ _ => ContextModifier :: None ,
9410
+ } ;
9411
+
9412
+ let role_name = if self . parse_keyword ( Keyword :: NONE ) {
9413
+ None
9414
+ } else {
9415
+ Some ( self . parse_identifier ( false ) ?)
9416
+ } ;
9417
+ Ok ( Statement :: SetRole {
9418
+ context_modifier,
9419
+ role_name,
9420
+ } )
9421
+ }
9422
+
9403
9423
pub fn parse_set ( & mut self ) -> Result < Statement , ParserError > {
9404
9424
let modifier =
9405
9425
self . parse_one_of_keywords ( & [ Keyword :: SESSION , Keyword :: LOCAL , Keyword :: HIVEVAR ] ) ;
9406
9426
if let Some ( Keyword :: HIVEVAR ) = modifier {
9407
9427
self . expect_token ( & Token :: Colon ) ?;
9408
- } else if self . parse_keyword ( Keyword :: ROLE ) {
9409
- let context_modifier = match modifier {
9410
- Some ( Keyword :: LOCAL ) => ContextModifier :: Local ,
9411
- Some ( Keyword :: SESSION ) => ContextModifier :: Session ,
9412
- _ => ContextModifier :: None ,
9413
- } ;
9414
-
9415
- let role_name = if self . parse_keyword ( Keyword :: NONE ) {
9416
- None
9417
- } else {
9418
- Some ( self . parse_identifier ( false ) ?)
9419
- } ;
9420
- return Ok ( Statement :: SetRole {
9421
- context_modifier,
9422
- role_name,
9423
- } ) ;
9428
+ } else if let Some ( set_role_stmt) =
9429
+ self . maybe_parse ( |parser| parser. parse_set_role ( modifier) )
9430
+ {
9431
+ return Ok ( set_role_stmt) ;
9424
9432
}
9425
9433
9426
9434
let variables = if self . parse_keywords ( & [ Keyword :: TIME , Keyword :: ZONE ] ) {
0 commit comments