Connection remains in failed transaction state after query error if rollback is not called
When using psycopg3, if a SQL execution fails and rollback() is not called, the connection remains in a failed transaction state, causing all subsequent queries to fail. This is standard PostgreSQL behavior, but it can be confusing and inconvenient for users who may forget to rollback manually.
I would like to propose an option in psycopg3 to automatically perform a rollback when the connection enters a failed transaction state, so that users are not required to handle this situation themselves every time.
If this idea is accepted, I am willing to help with the implementation.
Use case: • A query fails due to a constraint or syntax error. • Instead of requiring the user to call rollback(), psycopg3 could provide an option (e.g., auto_rollback_on_error=True) to automatically rollback the transaction, allowing subsequent queries to proceed without manual intervention.
Would the maintainers be open to this feature? If so, I can contribute a PR.