Skip to content

Commit

Permalink
Fix issue #385 (#386)
Browse files Browse the repository at this point in the history
Adds missing check for `TransactionStmtKind::Start` when verifying the existence of transactions as this is the same as using BEGIN: https://www.postgresql.org/docs/current/sql-begin.html

Fixes #385
  • Loading branch information
bmbferreira authored Oct 9, 2024
1 parent 0019f41 commit 12aa7b6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ pub fn ban_concurrent_index_creation_in_transaction(
for raw_stmt in tree {
match &raw_stmt.stmt {
Stmt::TransactionStmt(stmt) => {
if stmt.kind == TransactionStmtKind::Begin && !in_transaction {
if (stmt.kind == TransactionStmtKind::Begin
|| stmt.kind == TransactionStmtKind::Start)
&& !in_transaction
{
in_transaction = true;
}
if stmt.kind == TransactionStmtKind::Commit {
Expand Down
5 changes: 4 additions & 1 deletion linter/src/rules/constraint_missing_not_valid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ fn not_valid_validate_in_transaction(tree: &[RawStmt], assume_in_transaction: bo
for raw_stmt in tree {
match &raw_stmt.stmt {
Stmt::TransactionStmt(stmt) => {
if stmt.kind == TransactionStmtKind::Begin && !in_transaction {
if (stmt.kind == TransactionStmtKind::Begin
|| stmt.kind == TransactionStmtKind::Start)
&& !in_transaction
{
in_transaction = true;
not_valid_names.clear();
}
Expand Down
4 changes: 3 additions & 1 deletion linter/src/rules/prefer_robust_stmts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ pub fn prefer_robust_stmts(
for raw_stmt in tree {
match &raw_stmt.stmt {
Stmt::TransactionStmt(stmt) => match stmt.kind {
TransactionStmtKind::Begin => inside_transaction = true,
TransactionStmtKind::Begin | TransactionStmtKind::Start => {
inside_transaction = true;
}
TransactionStmtKind::Commit => inside_transaction = false,
_ => continue,
},
Expand Down
4 changes: 3 additions & 1 deletion linter/src/rules/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ pub fn tables_created_in_transaction(
for raw_stmt in tree {
match &raw_stmt.stmt {
Stmt::TransactionStmt(stmt) => match stmt.kind {
TransactionStmtKind::Begin => inside_transaction = true,
TransactionStmtKind::Begin | TransactionStmtKind::Start => {
inside_transaction = true;
}
TransactionStmtKind::Commit => inside_transaction = false,
_ => continue,
},
Expand Down

0 comments on commit 12aa7b6

Please sign in to comment.