ext/pdo_pgsql: Fix the connection state left behind by a lazy fetch - #23065
Draft
KentarouTakeda wants to merge 1 commit into
Draft
ext/pdo_pgsql: Fix the connection state left behind by a lazy fetch#23065KentarouTakeda wants to merge 1 commit into
KentarouTakeda wants to merge 1 commit into
Conversation
KentarouTakeda
force-pushed
the
pdo-pgsql-lazy-fetch-drain
branch
from
August 5, 2026 16:13
1f18350 to
df8d70e
Compare
KentarouTakeda
force-pushed
the
pdo-pgsql-lazy-fetch-drain
branch
2 times, most recently
from
August 5, 2026 16:24
1019743 to
a698573
Compare
KentarouTakeda
force-pushed
the
pdo-pgsql-lazy-fetch-drain
branch
from
August 5, 2026 16:28
a698573 to
1a30f7e
Compare
Contributor
Author
|
Converting to draft: the drain loop this restores can hang when the statement left the connection in a COPY state. I will update once that is sorted out. |
KentarouTakeda
marked this pull request as draft
August 5, 2026 17:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
ATTR_EMULATE_PREPARESorATTR_DISABLE_PREPARES, a lazy fetch (PDO::ATTR_PREFETCH => 0) left the connection busy once it ended, so the next one failed withSQLSTATE[HY000]: another command is already in progress. The cleanup drains the rest of the result set only while the statement is flagged as streaming, and both callers cleared that flag before calling it; let the cleanup clear it itself.Such a statement also never cleared the connection's pointer to itself, so destroying it left the connection pointing at freed memory for the next lazy fetch to read. Clear the pointer when the statement is destroyed, unless the connection object is gone too.
Independently of how it was prepared, a statement whose stream was taken over by another kept its row counters after its result was freed, so
fetch()returned a row of NULLs instead offalse. Check the result before trusting the counters.