Skip to content

Commit

Permalink
Send WARNING instead of NOTICE when trying to commit with no active tx
Browse files Browse the repository at this point in the history
Postgres sends a WARNING in this case instead of a NOTICE.
  • Loading branch information
andrioni committed Feb 14, 2022
1 parent 80e28b4 commit 24e4444
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/pgwire/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,10 +1095,10 @@ where
}
ExecuteResponse::TransactionExited { tag, was_implicit } => {
// In Postgres, if a user sends a COMMIT or ROLLBACK in an implicit
// transaction, a notice is sent warning them. (The transaction is still closed
// transaction, a warning is sent warning them. (The transaction is still closed
// and a new implicit transaction started, though.)
if was_implicit {
let msg = ErrorResponse::notice(
let msg = ErrorResponse::warning(
SqlState::NO_ACTIVE_SQL_TRANSACTION,
"there is no transaction in progress",
);
Expand Down
10 changes: 5 additions & 5 deletions test/pgtest/transactions.pt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Query {"query": "COMMIT;"}
Query {"query": "ROLLBACK;"}
----

until
until err_field_typs=SCM
ReadyForQuery
ReadyForQuery
ReadyForQuery
Expand All @@ -154,7 +154,7 @@ ReadyForQuery
RowDescription {"fields":[{"name":"?column?"}]}
DataRow {"fields":["1"]}
CommandComplete {"tag":"SELECT 1"}
NoticeResponse {"fields":[{"typ":"C","value":"25P01"},{"typ":"M","value":"there is no transaction in progress"}]}
NoticeResponse {"fields":[{"typ":"S","value":"WARNING"},{"typ":"C","value":"25P01"},{"typ":"M","value":"there is no transaction in progress"}]}
CommandComplete {"tag":"COMMIT"}
RowDescription {"fields":[{"name":"?column?"}]}
DataRow {"fields":["2"]}
Expand All @@ -163,16 +163,16 @@ ReadyForQuery {"status":"I"}
RowDescription {"fields":[{"name":"?column?"}]}
DataRow {"fields":["3"]}
CommandComplete {"tag":"SELECT 1"}
NoticeResponse {"fields":[{"typ":"C","value":"25P01"},{"typ":"M","value":"there is no transaction in progress"}]}
NoticeResponse {"fields":[{"typ":"S","value":"WARNING"},{"typ":"C","value":"25P01"},{"typ":"M","value":"there is no transaction in progress"}]}
CommandComplete {"tag":"ROLLBACK"}
RowDescription {"fields":[{"name":"?column?"}]}
DataRow {"fields":["4"]}
CommandComplete {"tag":"SELECT 1"}
ReadyForQuery {"status":"I"}
NoticeResponse {"fields":[{"typ":"C","value":"25P01"},{"typ":"M","value":"there is no transaction in progress"}]}
NoticeResponse {"fields":[{"typ":"S","value":"WARNING"},{"typ":"C","value":"25P01"},{"typ":"M","value":"there is no transaction in progress"}]}
CommandComplete {"tag":"COMMIT"}
ReadyForQuery {"status":"I"}
NoticeResponse {"fields":[{"typ":"C","value":"25P01"},{"typ":"M","value":"there is no transaction in progress"}]}
NoticeResponse {"fields":[{"typ":"S","value":"WARNING"},{"typ":"C","value":"25P01"},{"typ":"M","value":"there is no transaction in progress"}]}
CommandComplete {"tag":"ROLLBACK"}
ReadyForQuery {"status":"I"}

Expand Down

0 comments on commit 24e4444

Please sign in to comment.