Re: cvs: php4 /ext/pgsql pgsql.c
| From: | Thies C. Arntzen | Date: | Thu, 24 Jan 2002 12:40:08 +0000 |
| Subject: | Re: cvs: php4 /ext/pgsql pgsql.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-9149@lists.php.net to get a copy of this message | ||
On Thu, Jan 24, 2002 at 09:27:43AM -0000, Yasuo Ohgaki wrote:
> yohgaki Thu Jan 24 04:27:43 2002 EDT
>
> Modified files:
> /php4/ext/pgsql pgsql.c
> Log:
> Revert last 2 commit. Instead, make php_pgsql_do_connect() to catch
> broken connection always.
> # I think this is better than check&reset connection when query
> # functions are called.
this slows down every singe call to pg_[p]connect - as it
forces 1 server roundtrip even if none is needed. please make
this "ping" funtionality optional and configurable in php.ini
(default should be off - this is how it used to be)
i have a few high-volume postgres installations an i don't
want this extra overhead.
re,
tc
>
>
> Index: php4/ext/pgsql/pgsql.c
> diff -u php4/ext/pgsql/pgsql.c:1.144 php4/ext/pgsql/pgsql.c:1.145
> --- php4/ext/pgsql/pgsql.c:1.144 Thu Jan 24 01:40:10 2002
> +++ php4/ext/pgsql/pgsql.c Thu Jan 24 04:27:43 2002
> @@ -19,7 +19,7 @@
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: pgsql.c,v 1.144 2002/01/24 06:40:10 yohgaki Exp $ */
> +/* $Id: pgsql.c,v 1.145 2002/01/24 09:27:43 yohgaki Exp $ */
>
> #include <stdlib.h>
>
> @@ -535,15 +535,29 @@
> PGG(num_links)++;
> PGG(num_persistent)++;
> } else { /* we do */
> + php_log_err("CONNECTION IS ALREADY OPENED :)" TSRMLS_CC);
> if (Z_TYPE_P(le) != le_plink) {
> RETURN_FALSE;
> }
> /* ensure that the link did not die */
> + {
> + /* need to send & get something from backend to
> + make sure we catch CONNECTION_BAD everytime */
> + PGresult *pg_result;
> + pg_result = PQexec(le->ptr, "select 1");
> + PQclear(pg_result);
> + }
> + PQconsumeInput(le->ptr);
> if (PQstatus(le->ptr)==CONNECTION_BAD) { /* the link died */
> - if (connstring) {
> - le->ptr=PQconnectdb(connstring);
> - } else {
> - le->ptr=PQsetdb(host,port,options,tty,dbname);
> + if (le->ptr == NULL) {
> + if (connstring) {
> + le->ptr=PQconnectdb(connstring);
> + } else {
> + le->ptr=PQsetdb(host,port,options,tty,dbname);
> + }
> + }
> + else {
> + PQreset(le->ptr);
> }
> if (le->ptr==NULL || PQstatus(le->ptr)==CONNECTION_BAD) {
> php_error(E_WARNING,"PostgreSQL link lost, unable to reconnect");
> @@ -721,9 +735,6 @@
>
> ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link,
> le_plink);
>
> - if (PQstatus(pgsql) != CONNECTION_OK) {
> - PQreset(pgsql);
> - }
> switch(entry_type) {
> case PHP_PG_DBNAME:
> Z_STRVAL_P(return_value) = PQdb(pgsql);
> @@ -832,9 +843,6 @@
>
> ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link,
> le_plink);
>
> - if (PQstatus(pgsql) != CONNECTION_OK) {
> - PQreset(pgsql);
> - }
> convert_to_string_ex(query);
> PQsetnonblocking(pgsql, 0);
> while ((pgsql_result = PQgetResult(pgsql))) {
> @@ -2516,9 +2524,6 @@
>
> ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link",
> le_link, le_plink);
>
> - if (PQstatus(pgsql) != CONNECTION_OK) {
> - PQreset(pgsql);
> - }
> if (PQsetnonblocking(pgsql, 1)) {
> php_error(E_NOTICE,"%s() cannot set connection to nonblocking mode",
> get_active_function_name(TSRMLS_C));
>
>
>
> --
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net
> For additional commands, e-mail: php-cvs-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>