Bug #78980 [PATCH]: pgsqlGetNotify() overlooks dead connection

From: Date: Tue, 17 Dec 2019 17:27:33 +0000
Subject: Bug #78980 [PATCH]: pgsqlGetNotify() overlooks dead connection
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224361@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78980&edit=1 ID: 78980 Patch added by: kentaro@ranvis.com Reported by: kentaro at ranvis dot com Summary: pgsqlGetNotify() overlooks dead connection Status: Open Type: Bug Package: PDO PgSQL PHP Version: master-Git-2019-12-17 (Git) Block user comment: N Private report: N New Comment: The following pull request has been associated: Patch Name: Fix #78980: pgsqlGetNotify() overlooks dead connection On GitHub: https://github.com/php/php-src/pull/5020 Patch: https://github.com/php/php-src/pull/5020.patch Previous Comments: ------------------------------------------------------------------------ [2019-12-17 17:21:44] kentaro at ranvis dot com Description: ------------ 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: --------------- <?php $connArgs = ['pgsql:dbname=DB_NAME', 'USER', 'PASSWORD', [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ]]; $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') ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78980&edit=1

« previous php.bugs (#224361) next »