]> granicus.if.org Git - php/commitdiff
Added persistent connection status checker to pdo_pgsql
authorIlia Alshanetsky <iliaa@php.net>
Wed, 27 Jun 2007 02:00:46 +0000 (02:00 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 27 Jun 2007 02:00:46 +0000 (02:00 +0000)
NEWS
ext/pdo_pgsql/pgsql_driver.c

diff --git a/NEWS b/NEWS
index 8c27a3996f5a5d4e5e1deaa7ed885356ae725903..bdb4adff739cdba35e5b565b75c7386b19480f04 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,8 @@ PHP                                                                        NEWS
 - Changed error handler to send HTTP 500 instead of blank page on PHP errors.
   (Dmitry, Andrei Nigmatulin)
 
+- Added persistent connection status checker to pdo_pgsql (Elvis
+  Pranskevichus, Ilia)
 - Added php_ini_loaded_file() function which returns the path to the actual
   php.ini in use. (Jani)
 - Added GD version constants GD_MAJOR_VERSION, GD_MINOR_VERSION
index 92ee788f3c3e2fa0fe22c62d17df5f614ccf1eab..6727c6b8de35b8878f4cfd410871d191c0d7c3a2 100644 (file)
@@ -476,6 +476,17 @@ static int pdo_pgsql_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value
        return 1;
 }
 
+/* {{{ */
+static int pdo_pgsql_check_liveness(pdo_dbh_t *dbh TSRMLS_DC)
+{
+       pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
+       if (PQstatus(H->server) == CONNECTION_BAD) {
+               PQreset(H->server);
+       }
+       return (PQstatus(H->server) == CONNECTION_OK) ? SUCCESS : FAILURE;
+}
+/* }}} */
+
 static int pdo_pgsql_transaction_cmd(const char *cmd, pdo_dbh_t *dbh TSRMLS_DC)
 {
        pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
@@ -650,7 +661,7 @@ static struct pdo_dbh_methods pgsql_methods = {
        pdo_pgsql_last_insert_id,
        pdo_pgsql_fetch_error_func,
        pdo_pgsql_get_attribute,
-       NULL,   /* check_liveness */
+       pdo_pgsql_check_liveness,       /* check_liveness */
        pdo_pgsql_get_driver_methods  /* get_driver_methods */
 };