This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 05af09cd PostgreSQL: add support for `ABORT TRANSACTION` (#2332)
05af09cd is described below
commit 05af09cd1ddc3e56419dc48b5d5b0bfdce7d89fd
Author: Ning Sun <[email protected]>
AuthorDate: Mon May 18 05:58:25 2026 -0700
PostgreSQL: add support for `ABORT TRANSACTION` (#2332)
---
src/parser/mod.rs | 15 +++++++++++++++
tests/sqlparser_common.rs | 16 ++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 9655a580..763b876d 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -675,6 +675,7 @@ impl<'a> Parser<'a> {
self.parse_throw().map(Into::into)
}
Keyword::ROLLBACK => self.parse_rollback(),
+ Keyword::ABORT => self.parse_abort(),
Keyword::ASSERT => self.parse_assert(),
// `PREPARE`, `EXECUTE` and `DEALLOCATE` are Postgres-specific
// syntaxes. They are used for Postgres prepared statement.
@@ -19393,6 +19394,20 @@ impl<'a> Parser<'a> {
Ok(Statement::Rollback { chain, savepoint })
}
+ /// Parse an 'ABORT' statement
+ ///
+ /// ```sql
+ /// ABORT [ TRANSACTION | WORK ] [ AND [ NO ] CHAIN ]
+ /// ```
+ pub fn parse_abort(&mut self) -> Result<Statement, ParserError> {
+ let chain = self.parse_commit_rollback_chain()?;
+
+ Ok(Statement::Rollback {
+ chain,
+ savepoint: None,
+ })
+ }
+
/// Parse an optional `AND [NO] CHAIN` clause for `COMMIT` and `ROLLBACK`
statements
pub fn parse_commit_rollback_chain(&mut self) -> Result<bool, ParserError>
{
let _ = self.parse_one_of_keywords(&[Keyword::TRANSACTION,
Keyword::WORK, Keyword::TRAN]);
diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs
index b36998bf..bcf3c1d5 100644
--- a/tests/sqlparser_common.rs
+++ b/tests/sqlparser_common.rs
@@ -9536,6 +9536,22 @@ fn parse_rollback() {
);
}
+#[test]
+fn parse_abort() {
+ one_statement_parses_to("ABORT", "ROLLBACK");
+ one_statement_parses_to("ABORT TRANSACTION", "ROLLBACK");
+ one_statement_parses_to("ABORT WORK", "ROLLBACK");
+ one_statement_parses_to("ABORT AND CHAIN", "ROLLBACK AND CHAIN");
+ one_statement_parses_to("ABORT AND NO CHAIN", "ROLLBACK");
+ one_statement_parses_to("ABORT TRANSACTION AND CHAIN", "ROLLBACK AND
CHAIN");
+ one_statement_parses_to("ABORT WORK AND NO CHAIN", "ROLLBACK");
+
+ assert_eq!(
+ parse_sql_statements("ABORT TO test1").unwrap_err(),
+ ParserError::ParserError("Expected: end of statement, found:
TO".to_string()),
+ );
+}
+
#[test]
#[should_panic(expected = "Parse results with GenericDialect are different
from PostgreSqlDialect")]
fn ensure_multiple_dialects_are_tested() {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]