Skip to content

Commit 3203d7a

Browse files
committed
add support for abort and end
1 parent 54aa516 commit 3203d7a

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/parser.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,11 @@ impl<'a> Parser<'a> {
427427
Keyword::BEGIN => Ok(self.parse_begin()?),
428428
Keyword::SAVEPOINT => Ok(self.parse_savepoint()?),
429429
Keyword::COMMIT => Ok(self.parse_commit()?),
430+
Keyword::END if dialect_of!(self is PostgreSqlDialect) => Ok(self.parse_commit()?),
430431
Keyword::ROLLBACK => Ok(self.parse_rollback()?),
432+
Keyword::ABORT if dialect_of!(self is PostgreSqlDialect) => {
433+
Ok(self.parse_rollback()?)
434+
}
431435
Keyword::ASSERT => Ok(self.parse_assert()?),
432436
// `PREPARE`, `EXECUTE` and `DEALLOCATE` are Postgres-specific
433437
// syntaxes. They are used for Postgres prepared statement.

tests/sqlparser_postgres.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2878,3 +2878,25 @@ fn parse_create_mirror() {
28782878
_ => unreachable!(),
28792879
}
28802880
}
2881+
2882+
#[test]
2883+
fn parse_abort() {
2884+
match pg().verified_stmt("ROLLBACK") {
2885+
Statement::Rollback { chain: false } => (),
2886+
_ => unreachable!(),
2887+
}
2888+
pg().one_statement_parses_to("ABORT", "ROLLBACK");
2889+
pg().one_statement_parses_to("ABORT WORK", "ROLLBACK");
2890+
pg().one_statement_parses_to("ABORT TRANSACTION", "ROLLBACK");
2891+
}
2892+
2893+
#[test]
2894+
fn parse_end() {
2895+
match pg().verified_stmt("COMMIT") {
2896+
Statement::Commit { chain: false } => (),
2897+
_ => unreachable!(),
2898+
}
2899+
pg().one_statement_parses_to("END", "COMMIT");
2900+
pg().one_statement_parses_to("END WORK", "COMMIT");
2901+
pg().one_statement_parses_to("END TRANSACTION", "COMMIT");
2902+
}

0 commit comments

Comments
 (0)