cvs: php4 /ext/pgsql pgsql.c php_pgsql.h

From: Date: Wed, 04 Apr 2001 21:40:41 +0000
Subject: cvs: php4 /ext/pgsql pgsql.c php_pgsql.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-4986@lists.php.net to get a copy of this message
thies Wed Apr 4 14:40:41 2001 EDT Modified files: /php4/ext/pgsql pgsql.c php_pgsql.h Log: make it compile with 6.5.x postgresql notices are now send to the standard error-log Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.95 php4/ext/pgsql/pgsql.c:1.96 --- php4/ext/pgsql/pgsql.c:1.95 Mon Mar 26 00:00:43 2001 +++ php4/ext/pgsql/pgsql.c Wed Apr 4 14:40:41 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.95 2001/03/26 08:00:43 romolo Exp $ */ +/* $Id: pgsql.c,v 1.96 2001/04/04 21:40:41 thies Exp $ */ #include <stdlib.h> @@ -148,23 +148,25 @@ PGG(num_links)--; } -static void _be_quiet(void * arg, const char * message) + +static void +_notice_handler(void *arg, const char *message) { + PGLS_FETCH(); + + if (! PGG(ignore_notices)) { + php_log_err(message); + } } + static int _rollback_transactions(zend_rsrc_list_entry *rsrc) { PGconn *link = (PGconn *)rsrc->ptr; - PQnoticeProcessor old_notice_hook; - - /* we set the PQsetNoticeProcessor to avoid the stupid - * "NOTICE: BEGIN: already a transaction in progress" - * message - */ - old_notice_hook = PQsetNoticeProcessor(link, _be_quiet, NULL); + PGG(ignore_notices) = 1; PQexec(link,"BEGIN;ROLLBACK;"); - PQsetNoticeProcessor(link, old_notice_hook, NULL); + PGG(ignore_notices) = 0; return 0; } @@ -194,6 +196,7 @@ static void php_pgsql_init_globals(PGLS_D) { PGG(num_persistent) = 0; + PGG(ignore_notices) = 0; } PHP_MINIT_FUNCTION(pgsql) @@ -262,6 +265,8 @@ DISPLAY_INI_ENTRIES(); } + + void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent) { char *host=NULL,*port=NULL,*options=NULL,*tty=NULL,*dbname=NULL,*connstring=NULL; @@ -377,6 +382,8 @@ RETURN_FALSE; } + PQsetNoticeProcessor(pgsql, _notice_handler, NULL); + /* hash it up */ new_le.type = le_plink; new_le.ptr = pgsql; @@ -405,6 +412,8 @@ } } pgsql = (PGconn *) le->ptr; + + PQsetNoticeProcessor(pgsql, _notice_handler, NULL); } ZEND_REGISTER_RESOURCE(return_value, pgsql, le_plink); } else { @@ -450,6 +459,8 @@ efree(hashed_details); RETURN_FALSE; } + + PQsetNoticeProcessor(pgsql, _notice_handler, NULL); /* add it to the list */ ZEND_REGISTER_RESOURCE(return_value, pgsql, le_link); Index: php4/ext/pgsql/php_pgsql.h diff -u php4/ext/pgsql/php_pgsql.h:1.28 php4/ext/pgsql/php_pgsql.h:1.29 --- php4/ext/pgsql/php_pgsql.h:1.28 Sun Feb 25 22:07:12 2001 +++ php4/ext/pgsql/php_pgsql.h Wed Apr 4 14:40:41 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pgsql.h,v 1.28 2001/02/26 06:07:12 andi Exp $ */ +/* $Id: php_pgsql.h,v 1.29 2001/04/04 21:40:41 thies Exp $ */ #ifndef PHP_PGSQL_H #define PHP_PGSQL_H @@ -119,6 +119,7 @@ long max_links,max_persistent; long allow_persistent; int le_lofp,le_string; + int ignore_notices; } php_pgsql_globals;

« previous php.cvs (#4986) next »