File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -3774,7 +3774,12 @@ impl<'a> Parser<'a> {
37743774 } ) ;
37753775 }
37763776
3777- let variable = self . parse_object_name ( ) ?;
3777+ let variable = if self . parse_keywords ( & [ Keyword :: TIME , Keyword :: ZONE ] ) {
3778+ ObjectName ( vec ! [ "TIMEZONE" . into( ) ] )
3779+ } else {
3780+ self . parse_object_name ( ) ?
3781+ } ;
3782+
37783783 if variable. to_string ( ) . eq_ignore_ascii_case ( "NAMES" )
37793784 && dialect_of ! ( self is MySqlDialect | GenericDialect )
37803785 {
Original file line number Diff line number Diff line change @@ -4663,6 +4663,52 @@ fn parse_set_transaction() {
46634663 }
46644664}
46654665
4666+ #[ test]
4667+ fn parse_set_variable ( ) {
4668+ match verified_stmt ( "SET SOMETHING = '1'" ) {
4669+ Statement :: SetVariable {
4670+ local,
4671+ hivevar,
4672+ variable,
4673+ value,
4674+ } => {
4675+ assert ! ( !local) ;
4676+ assert ! ( !hivevar) ;
4677+ assert_eq ! ( variable, ObjectName ( vec![ "SOMETHING" . into( ) ] ) ) ;
4678+ assert_eq ! (
4679+ value,
4680+ vec![ Expr :: Value ( Value :: SingleQuotedString ( "1" . into( ) ) ) ]
4681+ ) ;
4682+ }
4683+ _ => unreachable ! ( ) ,
4684+ }
4685+
4686+ one_statement_parses_to ( "SET SOMETHING TO '1'" , "SET SOMETHING = '1'" ) ;
4687+ }
4688+
4689+ #[ test]
4690+ fn parse_set_time_zone ( ) {
4691+ match verified_stmt ( "SET TIMEZONE = 'UTC'" ) {
4692+ Statement :: SetVariable {
4693+ local,
4694+ hivevar,
4695+ variable,
4696+ value,
4697+ } => {
4698+ assert ! ( !local) ;
4699+ assert ! ( !hivevar) ;
4700+ assert_eq ! ( variable, ObjectName ( vec![ "TIMEZONE" . into( ) ] ) ) ;
4701+ assert_eq ! (
4702+ value,
4703+ vec![ Expr :: Value ( Value :: SingleQuotedString ( "UTC" . into( ) ) ) ]
4704+ ) ;
4705+ }
4706+ _ => unreachable ! ( ) ,
4707+ }
4708+
4709+ one_statement_parses_to ( "SET TIME ZONE TO 'UTC'" , "SET TIMEZONE = 'UTC'" ) ;
4710+ }
4711+
46664712#[ test]
46674713fn parse_commit ( ) {
46684714 match verified_stmt ( "COMMIT" ) {
You can’t perform that action at this time.
0 commit comments