Skip to content

Commit

Permalink
fix: recognize ABORT statements for PostgreSQL (#2479)
Browse files Browse the repository at this point in the history
PostgreSQL supports the `ABORT [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]`
statement in addition to the more common ROLLBACK.

See https://www.postgresql.org/docs/current/sql-abort.html
  • Loading branch information
olavloite authored Jun 28, 2023
1 parent 7c5b606 commit da47b0a
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 2,023 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,16 @@
"examplePrerequisiteStatements": ["begin transaction"]
},
{
"name": "ROLLBACK [TRANSACTION | WORK] [AND NO CHAIN]",
"name": "{ROLLBACK | ABORT} [TRANSACTION | WORK] [AND NO CHAIN]",
"executorName": "ClientSideStatementNoParamExecutor",
"resultType": "NO_RESULT",
"statementType": "ROLLBACK",
"regex": "(?is)\\A\\s*(?:rollback)(?:\\s+transaction|\\s+work)?(?:\\s+and\\s+no\\s+chain)?\\s*\\z",
"regex": "(?is)\\A\\s*(?:rollback|abort)(?:\\s+transaction|\\s+work)?(?:\\s+and\\s+no\\s+chain)?\\s*\\z",
"method": "statementRollback",
"exampleStatements": ["rollback", "rollback transaction", "rollback work", "rollback and no chain", "rollback transaction and no chain", "rollback work and no chain"],
"exampleStatements": [
"rollback", "rollback transaction", "rollback work", "rollback and no chain", "rollback transaction and no chain", "rollback work and no chain",
"abort", "abort transaction", "abort work", "abort and no chain", "abort transaction and no chain", "abort work and no chain"
],
"examplePrerequisiteStatements": ["begin transaction"]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ public void testClientSideStatementType() {
assertEquals(
ClientSideStatementType.ROLLBACK,
parser.parse(Statement.of("ROLLBACK TRANSACTION")).getClientSideStatementType());
if (dialect == Dialect.POSTGRESQL) {
assertEquals(
ClientSideStatementType.ROLLBACK,
parser.parse(Statement.of("ABORT")).getClientSideStatementType());
assertEquals(
ClientSideStatementType.ROLLBACK,
parser.parse(Statement.of("ABORT TRANSACTION")).getClientSideStatementType());
assertEquals(
ClientSideStatementType.ROLLBACK,
parser.parse(Statement.of("ABORT WORK")).getClientSideStatementType());
assertEquals(
ClientSideStatementType.ROLLBACK,
parser
.parse(Statement.of("ABORT TRANSACTION and no chain"))
.getClientSideStatementType());
}

for (ClientSideStatementImpl statement : parser.getClientSideStatements()) {
assertNotNull(
Expand Down
Loading

0 comments on commit da47b0a

Please sign in to comment.