Skip to content

ext/pdo_pgsql: Fix PDO::CURSOR_SCROLL statements failing under lazy fetching - #23471

Closed
KentarouTakeda wants to merge 1 commit into
php:PHP-8.5from
KentarouTakeda:fix-pdo-pgsql-cursor-lazy-fetch
Closed

ext/pdo_pgsql: Fix PDO::CURSOR_SCROLL statements failing under lazy fetching#23471
KentarouTakeda wants to merge 1 commit into
php:PHP-8.5from
KentarouTakeda:fix-pdo-pgsql-cursor-lazy-fetch

Conversation

@KentarouTakeda

Copy link
Copy Markdown
Contributor

A statement prepared with PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL and lazy fetching (PDO::ATTR_PREFETCH => 0) fails at execute() with SQLSTATE[HY000]: General error: 7 and no message. Either option alone works.

A cursor does not stream its result, but S->is_unbuffered stays set, so execute() calls PQgetResult() with nothing in flight. The fix clears the flag when the statement has a cursor.

The test is David Carlier's, from #23210.

Comment thread ext/pdo_pgsql/pgsql_driver.c Outdated
: H->default_fetching_laziness
;

if (scrollable) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: S->is_unbuffered computation above and setting it if scrollable should go up after scrollable computation wdyt ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied. Thanks.

@KentarouTakeda
KentarouTakeda force-pushed the fix-pdo-pgsql-cursor-lazy-fetch branch from a070d76 to bd15b50 Compare August 26, 2026 23:41
@KentarouTakeda
KentarouTakeda force-pushed the fix-pdo-pgsql-cursor-lazy-fetch branch from bd15b50 to b143c49 Compare August 26, 2026 23:42
@devnexen devnexen closed this in 197bdc0 Aug 27, 2026
@KentarouTakeda
KentarouTakeda deleted the fix-pdo-pgsql-cursor-lazy-fetch branch August 30, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants