File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -2026,7 +2026,7 @@ impl Parser {
20262026 TransactionMode :: AccessMode ( TransactionAccessMode :: ReadOnly )
20272027 } else if self . parse_keywords ( vec ! [ "READ" , "WRITE" ] ) {
20282028 TransactionMode :: AccessMode ( TransactionAccessMode :: ReadWrite )
2029- } else if required || self . peek_token ( ) . is_some ( ) {
2029+ } else if required {
20302030 self . expected ( "transaction mode" , self . peek_token ( ) ) ?
20312031 } else {
20322032 break ;
Original file line number Diff line number Diff line change @@ -2455,6 +2455,17 @@ fn parse_start_transaction() {
24552455 verified_stmt ( "START TRANSACTION ISOLATION LEVEL REPEATABLE READ" ) ;
24562456 verified_stmt ( "START TRANSACTION ISOLATION LEVEL SERIALIZABLE" ) ;
24572457
2458+ // Regression test for https://github.com/andygrove/sqlparser-rs/pull/139,
2459+ // in which START TRANSACTION would fail to parse if followed by a statement
2460+ // terminator.
2461+ assert_eq ! (
2462+ parse_sql_statements( "START TRANSACTION; SELECT 1" ) ,
2463+ Ok ( vec![
2464+ verified_stmt( "START TRANSACTION" ) ,
2465+ verified_stmt( "SELECT 1" ) ,
2466+ ] )
2467+ ) ;
2468+
24582469 let res = parse_sql_statements ( "START TRANSACTION ISOLATION LEVEL BAD" ) ;
24592470 assert_eq ! (
24602471 ParserError :: ParserError ( "Expected isolation level, found: BAD" . to_string( ) ) ,
@@ -2463,7 +2474,7 @@ fn parse_start_transaction() {
24632474
24642475 let res = parse_sql_statements ( "START TRANSACTION BAD" ) ;
24652476 assert_eq ! (
2466- ParserError :: ParserError ( "Expected transaction mode , found: BAD" . to_string( ) ) ,
2477+ ParserError :: ParserError ( "Expected end of statement , found: BAD" . to_string( ) ) ,
24672478 res. unwrap_err( )
24682479 ) ;
24692480
You can’t perform that action at this time.
0 commit comments