From: Michael Wallner Date: Wed, 6 Feb 2013 21:03:55 +0000 (+0100) Subject: only rollback if transaction status indicates need of action X-Git-Tag: v0.1.0~20 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-pq;a=commitdiff_plain;h=3bb2c115b2e3d14b2de84114dbffc58f3b71fae5;hp=a09c92a19b36f486762ff952fed6a9907946a1d5 only rollback if transaction status indicates need of action --- diff --git a/src/php_pq.c b/src/php_pq.c index e298d2b..a465eed 100644 --- a/src/php_pq.c +++ b/src/php_pq.c @@ -1803,8 +1803,9 @@ static void php_pqconn_persistent_resource_factory_dtor(void *opaque, void *hand { PGresult *res; + /* 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); }