Skip to content

Commit 37d11d1

Browse files
ranvisnikic
authored andcommitted
Fix #78982: pdo_pgsql returns dead persistent connection
Call PQconsumeInput() before PQstatus() to update the status.
1 parent 7e39e69 commit 37d11d1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ PHP NEWS
2626
Kentarō)
2727
. Fixed bug #78980 (pgsqlGetNotify() overlooks dead connection). (SATŌ
2828
Kentarō)
29+
. Fixed bug #78982 (pdo_pgsql returns dead persistent connection). (SATŌ
30+
Kentarō)
2931

3032
18 Dec 2019, PHP 7.3.13
3133

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static int pdo_pgsql_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_
479479
static int pdo_pgsql_check_liveness(pdo_dbh_t *dbh)
480480
{
481481
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
482-
if (PQstatus(H->server) == CONNECTION_BAD) {
482+
if (!PQconsumeInput(H->server) || PQstatus(H->server) == CONNECTION_BAD) {
483483
PQreset(H->server);
484484
}
485485
return (PQstatus(H->server) == CONNECTION_OK) ? SUCCESS : FAILURE;

0 commit comments

Comments
 (0)