File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -675,6 +675,7 @@ impl<'a> Parser<'a> {
675675 self.parse_throw().map(Into::into)
676676 }
677677 Keyword::ROLLBACK => self.parse_rollback(),
678+ Keyword::ABORT => self.parse_abort(),
678679 Keyword::ASSERT => self.parse_assert(),
679680 // `PREPARE`, `EXECUTE` and `DEALLOCATE` are Postgres-specific
680681 // syntaxes. They are used for Postgres prepared statement.
@@ -19393,6 +19394,20 @@ impl<'a> Parser<'a> {
1939319394 Ok(Statement::Rollback { chain, savepoint })
1939419395 }
1939519396
19397+ /// Parse an 'ABORT' statement
19398+ ///
19399+ /// ```sql
19400+ /// ABORT [ TRANSACTION | WORK ] [ AND [ NO ] CHAIN ]
19401+ /// ```
19402+ pub fn parse_abort(&mut self) -> Result<Statement, ParserError> {
19403+ let chain = self.parse_commit_rollback_chain()?;
19404+
19405+ Ok(Statement::Rollback {
19406+ chain,
19407+ savepoint: None,
19408+ })
19409+ }
19410+
1939619411 /// Parse an optional `AND [NO] CHAIN` clause for `COMMIT` and `ROLLBACK` statements
1939719412 pub fn parse_commit_rollback_chain(&mut self) -> Result<bool, ParserError> {
1939819413 let _ = self.parse_one_of_keywords(&[Keyword::TRANSACTION, Keyword::WORK, Keyword::TRAN]);
Original file line number Diff line number Diff line change @@ -9536,6 +9536,22 @@ fn parse_rollback() {
95369536 );
95379537}
95389538
9539+ #[test]
9540+ fn parse_abort() {
9541+ one_statement_parses_to("ABORT", "ROLLBACK");
9542+ one_statement_parses_to("ABORT TRANSACTION", "ROLLBACK");
9543+ one_statement_parses_to("ABORT WORK", "ROLLBACK");
9544+ one_statement_parses_to("ABORT AND CHAIN", "ROLLBACK AND CHAIN");
9545+ one_statement_parses_to("ABORT AND NO CHAIN", "ROLLBACK");
9546+ one_statement_parses_to("ABORT TRANSACTION AND CHAIN", "ROLLBACK AND CHAIN");
9547+ one_statement_parses_to("ABORT WORK AND NO CHAIN", "ROLLBACK");
9548+
9549+ assert_eq!(
9550+ parse_sql_statements("ABORT TO test1").unwrap_err(),
9551+ ParserError::ParserError("Expected: end of statement, found: TO".to_string()),
9552+ );
9553+ }
9554+
95399555#[test]
95409556#[should_panic(expected = "Parse results with GenericDialect are different from PostgreSqlDialect")]
95419557fn ensure_multiple_dialects_are_tested() {
You can’t perform that action at this time.
0 commit comments