only rollback if transaction status indicates need of action
[m6w6/ext-pq] / src / php_pq.c
index e298d2b8ea5aad37d728233abdfba1cc7ebf1811..a465eeddb99db1f52d0b133162a9d1d3bf6709eb 100644 (file)
@@ -1803,8 +1803,9 @@ static void php_pqconn_persistent_resource_factory_dtor(void *opaque, void *hand
 {
        PGresult *res;
 
 {
        PGresult *res;
 
+
        /* clean up */
        /* clean up */
-       if ((res = PQexec(handle, "ROLLBACK; RESET ALL;"))) {
+       if ((res = PQexec(handle, PQtransactionStatus(handle) == PQTRANS_IDLE ? "RESET ALL" : "ROLLBACK; RESET ALL"))) {
                PHP_PQclear(res);
        }
 
                PHP_PQclear(res);
        }