Drain libpq results before throwing#531
Merged
Merged
Conversation
Signed-off-by: Mark Nefedov <mvnefedov@avito.ru>
marknefedov
marked this pull request as ready for review
July 24, 2026 20:50
staticlibs
approved these changes
Jul 25, 2026
staticlibs
left a comment
Member
There was a problem hiding this comment.
Thanks for the PR! Looks good to me.
staticlibs
pushed a commit
that referenced
this pull request
Jul 25, 2026
This is a backport of the PR #531 to `v1.5-variegata` stable branch. Signed-off-by: Mark Nefedov <mvnefedov@avito.ru>
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.
PostgresConnection::ExecuteQueriesthrew astd::runtime_erroras soon as it saw a result with an error status, while still inside thePQgetResult()polling loop. This left the connection's result queue undrained — libpq expects every result to be pulled withPQgetResult()until it returnsNULLbefore the connection is reused. Bailing out early via an exception left stale/pending results on the connection, so the next query issued on that (pooled/reused) connection could get confused by leftover state.In
src/postgres_connection.cpp, the error path no longer throws immediately. Instead, it records the first error message andcontinues the loop so all remaining results are drained viaPQgetResult(). Only after the loop exits (i.e.PQgetResult()returnsNULL) is the preserved error thrown.