|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78980 pgsqlGetNotify() overlooks dead connection
Submitted: 2019-12-17 17:21 UTC Modified: -
From: kentaro at ranvis dot com Assigned:
Status: Closed Package: PDO PgSQL
PHP Version: master-Git-2019-12-17 (Git) OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: kentaro at ranvis dot com
New email:
PHP Version: OS:


 [2019-12-17 17:21 UTC] kentaro at ranvis dot com
pgsqlGetNotify() doesn't check the result of PQconsumeInput(),
which returns 0 on error.
If a caller is pooling by calling pgsqlGetNotify(),
it will never have a chance to known when the connection is lost.

(will add a PR)

Test script:

$connArgs = ['pgsql:dbname=DB_NAME', 'USER', 'PASSWORD', [
$pdo = new PDO(...$connArgs);
$pdo->exec('listen "test-event"');

var_dump($pdo->pgsqlGetNotify(PDO::FETCH_NUM, 1000));

sleep(15); // kill the DB connection here
//system('sudo systemctl restart postgresql-12');
//system('net stop postgresql-x64-12 && net start postgresql-x64-12');

var_dump($pdo->pgsqlGetNotify(PDO::FETCH_NUM, 1000)); // should throw but doesn't
var_dump($pdo->query('select 1')); // throws

Expected result:
throws on $pdo->pgsqlGetNotify()

Actual result:
throws after $pdo->pgsqlGetNotify(), on $pdo->query('select 1')


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-17 17:27 UTC] kentaro at ranvis dot com
The following pull request has been associated:

Patch Name: Fix #78980: pgsqlGetNotify() overlooks dead connection
On GitHub:
 [2019-12-20 10:46 UTC]
Automatic comment on behalf of
Log: Fix #78980: pgsqlGetNotify() overlooks dead connection
 [2019-12-20 10:46 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 08:01:28 2024 UTC