File tree 2 files changed +20
-6
lines changed
2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -1013,9 +1013,15 @@ fn parse_session_options(
1013
1013
let mut options: Vec < KeyValueOption > = Vec :: new ( ) ;
1014
1014
let empty = String :: new;
1015
1015
loop {
1016
- match parser. next_token ( ) . token {
1017
- Token :: Comma => continue ,
1016
+ let next_token = parser. peek_token ( ) ;
1017
+ match next_token. token {
1018
+ Token :: SemiColon | Token :: EOF => break ,
1019
+ Token :: Comma => {
1020
+ parser. advance_token ( ) ;
1021
+ continue ;
1022
+ }
1018
1023
Token :: Word ( key) => {
1024
+ parser. advance_token ( ) ;
1019
1025
if set {
1020
1026
let option = parse_option ( parser, key) ?;
1021
1027
options. push ( option) ;
@@ -1028,10 +1034,7 @@ fn parse_session_options(
1028
1034
}
1029
1035
}
1030
1036
_ => {
1031
- if parser. peek_token ( ) . token == Token :: EOF {
1032
- break ;
1033
- }
1034
- return parser. expected ( "another option" , parser. peek_token ( ) ) ;
1037
+ return parser. expected ( "another option or end of statement" , next_token) ;
1035
1038
}
1036
1039
}
1037
1040
}
Original file line number Diff line number Diff line change @@ -3505,3 +3505,14 @@ fn test_alter_session() {
3505
3505
) ;
3506
3506
snowflake ( ) . one_statement_parses_to ( "ALTER SESSION UNSET a\n B" , "ALTER SESSION UNSET a, B" ) ;
3507
3507
}
3508
+
3509
+ #[ test]
3510
+ fn test_alter_session_followed_by_statement ( ) {
3511
+ let stmts = snowflake ( )
3512
+ . parse_sql_statements ( "ALTER SESSION SET QUERY_TAG='hello'; SELECT 42" )
3513
+ . unwrap ( ) ;
3514
+ match stmts[ ..] {
3515
+ [ Statement :: AlterSession { .. } , Statement :: Query { .. } ] => { }
3516
+ _ => panic ! ( "Unexpected statements: {:?}" , stmts) ,
3517
+ }
3518
+ }
You can’t perform that action at this time.
0 commit comments