I have a very simple connection pooler in my application. When handing back a connection I need to ensure that no variables are set and no transaction is still on going. I understand that ROLLBACK; DISCARD ALL;
should be enough.
In most cases, if the transaction was successful, it will be committed before handing it over to the pooler and at this point, I will have a warning such as WARNING: there is no transaction in progress
.
Is there any way to execute a ROLLBACK
only if we are still in a transaction?
Or is there an other preferred method to cleanup a connection?