Commit should throw an error if it fails #3
davecramer
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
If the driver layer has a transaction entity instead of the application or ORM directly sending // Commit commits the transaction.
func (tx *dbTx) Commit(ctx context.Context) error {
// ...
commandTag, err := tx.conn.Exec(ctx, "commit")
// ... handle err
if commandTag.String() == "ROLLBACK" {
return ErrTxCommitRollback
}
return nil
} I agree that the current behavior is not ideal, and seems to be breaking the SQL spec. So this change might be reasonable, but it wouldn't affect pgx much either way -- especially since the old way would need to be supported for old servers. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently if you execute the following code
the error is thrown when the error occurs but the commit "succeeds" without an error message.
Here is the discussion on hackers https://www.postgresql.org/message-id/b9fb50dc-0f6e-15fb-6555-8ddb86f4aa71%40postgresfriends.org
Here's an attempt to fix it
https://commitfest.postgresql.org/32/2522/
I still think this behaviour is undesirable. I just don't see any support from the server community.
Beta Was this translation helpful? Give feedback.
All reactions