summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorThies C. Arntzen <thies@php.net>2001-02-13 18:28:24 +0000
committerThies C. Arntzen <thies@php.net>2001-02-13 18:28:24 +0000
commitf6925611fb40499e9c357d7f6d95a7a4c1a96308 (patch)
tree8fb9a50220382d1f5fc068129175c60ea6963162 /ext
parent79a38a1c3ae108b8aaeaa040bc1ad24337a396e1 (diff)
downloadphp-git-f6925611fb40499e9c357d7f6d95a7a4c1a96308.tar.gz
@- PostgreSQL now does a rollback at the end of a request on every
@ 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)
Diffstat (limited to 'ext')
-rw-r--r--ext/pgsql/pgsql.c35
-rw-r--r--ext/pgsql/php_pgsql.h1
2 files changed, 35 insertions, 1 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index ce4b7fc3b8..cbc09ba60f 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -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));
}
diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h
index 37071c8395..e53670a1af 100644
--- a/ext/pgsql/php_pgsql.h
+++ b/ext/pgsql/php_pgsql.h
@@ -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);