]> granicus.if.org Git - php/commitdiff
@- PostgreSQL now does a rollback at the end of a request on every
authorThies C. Arntzen <thies@php.net>
Tue, 13 Feb 2001 18:28:24 +0000 (18:28 +0000)
committerThies C. Arntzen <thies@php.net>
Tue, 13 Feb 2001 18:28:24 +0000 (18:28 +0000)
@  persistent connection. This is done by doing an "empty" transaction
@  on the connection (This was advised by someone from the PostgreSQL
@  core-team). If you leave transactions open on your page you will see a
@  "NOTICE:  BEGIN: already a transaction in progress" message in your
@  apache error_log. This message is created by the PostgreSQL libs - we can
@  do nothing about it. (Thies)

ext/pgsql/pgsql.c
ext/pgsql/php_pgsql.h

index ce4b7fc3b8c73d6f1a58ac10e86b780e64aae756..cbc09ba60f9f980bdba076aa2b6cba3dd8c6bb73 100644 (file)
@@ -93,7 +93,7 @@ zend_module_entry pgsql_module_entry = {
        PHP_MINIT(pgsql),
        PHP_MSHUTDOWN(pgsql),
        PHP_RINIT(pgsql),
-       NULL,
+       PHP_RSHUTDOWN(pgsql),
        PHP_MINFO(pgsql),
        STANDARD_MODULE_PROPERTIES
 };
@@ -145,6 +145,29 @@ static void _close_pgsql_plink(zend_rsrc_list_entry *rsrc)
        PGG(num_links)--;
 }
 
+static int _rollback_transactions(zend_rsrc_list_entry *rsrc)
+{
+       PGconn *link = (PGconn *)rsrc->ptr;
+       /*
+       PGresult *pg_result;
+       ExecStatusType status;
+       */
+
+       PQexec(link,"BEGIN;ROLLBACK;");
+
+       /* maybe do error handling later....
+       pg_result = PQexec(link,"BEGIN;ROLLBACK;");
+       
+       if (pg_result) {
+               status = PQresultStatus(pg_result);
+       } else {
+               status = (ExecStatusType) PQstatus(link);
+       }
+       */
+
+       return 0;
+}
+
 
 static void _free_ptr(zend_rsrc_list_entry *rsrc)
 {
@@ -213,6 +236,14 @@ PHP_RINIT_FUNCTION(pgsql)
        return SUCCESS;
 }
 
+PHP_RSHUTDOWN_FUNCTION(pgsql)
+{
+       zend_hash_apply(&EG(persistent_list),_rollback_transactions);
+
+       return SUCCESS;
+}
+
+
 
 PHP_MINFO_FUNCTION(pgsql)
 {
@@ -491,6 +522,8 @@ PHP_FUNCTION(pg_close)
        
        ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
 
+       printf("\npg_close %d\n",id);
+
        if (id==-1) { /* explicit resource number */
                zend_list_delete(Z_RESVAL_PP(pgsql_link));
        }
index 37071c83957d3c2c17fa4f80516554184a0933ba..e53670a1af4496f32bbf93140c7f9f969655b1c6 100644 (file)
@@ -48,6 +48,7 @@ extern zend_module_entry pgsql_module_entry;
 PHP_MINIT_FUNCTION(pgsql);
 PHP_MSHUTDOWN_FUNCTION(pgsql);
 PHP_RINIT_FUNCTION(pgsql);
+PHP_RSHUTDOWN_FUNCTION(pgsql);
 PHP_MINFO_FUNCTION(pgsql);
 PHP_FUNCTION(pg_connect);
 PHP_FUNCTION(pg_pconnect);