yohgaki Sun Feb 9 02:24:37 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/pgsql pgsql.c Log: MFH Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.244.2.7 php4/ext/pgsql/pgsql.c:1.244.2.8 --- php4/ext/pgsql/pgsql.c:1.244.2.7 Tue Feb 4 13:34:10 2003 +++ php4/ext/pgsql/pgsql.c Sun Feb 9 02:24:36 2003 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.244.2.7 2003/02/04 18:34:10 iliaa Exp $ */ +/* $Id: pgsql.c,v 1.244.2.8 2003/02/09 07:24:36 yohgaki Exp $ */ #include <stdlib.h> @@ -579,7 +579,7 @@ RETURN_FALSE; } /* ensure that the link did not die */ - if (PGG(auto_reset_persistent)) { + if (PGG(auto_reset_persistent) & 1) { /* need to send & get something from backend to make sure we catch CONNECTION_BAD everytime */ PGresult *pg_result; @@ -930,7 +930,12 @@ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Found results on this connection. Use pg_get_result() to get these results first."); } pgsql_result = PQexec(pgsql, Z_STRVAL_PP(query)); - + if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) { + PQclear(pgsql_result); + PQreset(pgsql); + pgsql_result = PQexec(pgsql, Z_STRVAL_PP(query)); + } + if (pgsql_result) { status = PQresultStatus(pgsql_result); } else { @@ -951,7 +956,7 @@ pg_result = (pgsql_result_handle *) emalloc(sizeof(pgsql_result_handle)); pg_result->conn = pgsql; pg_result->result = pgsql_result; - pg_result->row = -1; + pg_result->row = 0; ZEND_REGISTER_RESOURCE(return_value, pg_result, le_result); } else { RETURN_FALSE; @@ -1301,11 +1306,11 @@ pgsql_result = pg_result->result; if (ZEND_NUM_ARGS() == 1) { - pg_result->row++; pgsql_row = pg_result->row; if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) { RETURN_FALSE; } + pg_result->row++; } else { if (Z_TYPE_PP(row) != IS_NULL) { convert_to_long_ex(row); @@ -1317,11 +1322,11 @@ } } else { /* If 2nd param is NULL, use internal row counter to access next row */ - pg_result->row++; pgsql_row = pg_result->row; if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) { RETURN_FALSE; } + pg_result->row++; } } array_init(return_value); @@ -1448,7 +1453,7 @@ } /* seek to offset */ - pg_result->row = row - 1; + pg_result->row = row; RETURN_TRUE; } /* }}} */ @@ -2934,7 +2939,12 @@ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "There are results on this connection. Call pg_get_result() until it returns FALSE."); } if (!PQsendQuery(pgsql, query)) { - RETURN_FALSE; + if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != +CONNECTION_OK) { + PQreset(pgsql); + } + if (!PQsendQuery(pgsql, query)) { + RETURN_FALSE; + } } if (PQ_SETNONBLOCKING(pgsql, 0)) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot set connection to blocking mode.");
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php