thies Tue Feb 13 10:28:25 2001 EDT
Modified files:
/php4/ext/pgsql pgsql.c php_pgsql.h
Log:
@- 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)
Index: php4/ext/pgsql/pgsql.c
diff -u php4/ext/pgsql/pgsql.c:1.86 php4/ext/pgsql/pgsql.c:1.87
--- php4/ext/pgsql/pgsql.c:1.86 Tue Feb 13 08:54:48 2001
+++ php4/ext/pgsql/pgsql.c Tue Feb 13 10:28:24 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pgsql.c,v 1.86 2001/02/13 16:54:48 thies Exp $ */
+/* $Id: pgsql.c,v 1.87 2001/02/13 18:28:24 thies Exp $ */
#include <stdlib.h>
@@ -93,7 +93,7 @@
PHP_MINIT(pgsql),
PHP_MSHUTDOWN(pgsql),
PHP_RINIT(pgsql),
- NULL,
+ PHP_RSHUTDOWN(pgsql),
PHP_MINFO(pgsql),
STANDARD_MODULE_PROPERTIES
};
@@ -145,7 +145,30 @@
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)
{
pgLofp *lofp = (pgLofp *)rsrc->ptr;
@@ -213,7 +236,15 @@
return SUCCESS;
}
+PHP_RSHUTDOWN_FUNCTION(pgsql)
+{
+ zend_hash_apply(&EG(persistent_list),_rollback_transactions);
+
+ return SUCCESS;
+}
+
+
PHP_MINFO_FUNCTION(pgsql)
{
char buf[32];
@@ -490,6 +521,8 @@
}
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: php4/ext/pgsql/php_pgsql.h
diff -u php4/ext/pgsql/php_pgsql.h:1.24 php4/ext/pgsql/php_pgsql.h:1.25
--- php4/ext/pgsql/php_pgsql.h:1.24 Thu Jan 18 14:17:05 2001
+++ php4/ext/pgsql/php_pgsql.h Tue Feb 13 10:28:24 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pgsql.h,v 1.24 2001/01/18 22:17:05 derick Exp $ */
+/* $Id: php_pgsql.h,v 1.25 2001/02/13 18:28:24 thies Exp $ */
#ifndef PHP_PGSQL_H
#define PHP_PGSQL_H
@@ -48,6 +48,7 @@
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);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]