You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pdo_pgsql throws with ATTR_PREFETCH=0 on empty result set #21683
<?php$pdo = newPDO('pgsql:...');
$pdo->setAttribute(PDO::ATTR_PREFETCH, 0);
$pdo->exec("CREATE TEMP TABLE empty_t (id int, val text)");
$stmt = $pdo->query("SELECT * FROM empty_t");
var_dump($stmt->fetch());
Resulted in this output:
PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 7 in Command line code:9
But I expected this output instead:
bool(false)
PHP Version
PHP 8.5.4 (cli) (built: Mar 10 2026 23:15:23) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.5.4, Copyright (c) Zend Technologies
with Zend OPcache v8.5.4, Copyright (c), by Zend Technologies
changed the title [-]pdo_pgsql crashes with ATTR_PREFETCH=0 on empty result set[/-][+]pdo_pgsql throws with ATTR_PREFETCH=0 on empty result set[/+]on Apr 9, 2026
Activity
devnexen commentedon Apr 9, 2026
the fix seems right, what is your libpq version by any chance ?
it seems to me it is "just" an exception raised rather than a crash.
[-]pdo_pgsql crashes with ATTR_PREFETCH=0 on empty result set[/-][+]pdo_pgsql throws with ATTR_PREFETCH=0 on empty result set[/+]thomasschiet commentedon Apr 9, 2026
Indeed, this just throws
PDOExceptionI tested this on postgres 17.7 / libpq 5.17.
MrSuddenJoy commentedon Apr 12, 2026
If only PG started.......
Fix GH-21683: PDOStatement::fetch() throws on empty result With PDO::…
Merge branch 'PHP-8.5'