diff options
author | Alvaro Herrera | 2023-12-05 11:43:24 +0000 |
---|---|---|
committer | Alvaro Herrera | 2023-12-05 11:43:24 +0000 |
commit | b8ba7344e9eb9bb505a92900b2a59257ef718135 (patch) | |
tree | e4bb14dbecc0d7d422572e5e7dc17c30071c37ad /src/interfaces/libpq/libpq-int.h | |
parent | 63c5df126abb7364b70dafe75fef576dd8eb0bbc (diff) |
Fix handling of errors in libpq pipelines
The logic to keep the libpq command queue in sync with queries that have
been processed had a bug when errors were returned for reasons other
than problems in queries -- for example, when a connection is lost. We
incorrectly consumed an element from the command queue every time, but
this is wrong and can lead to the queue becoming empty ahead of time,
leading to later malfunction: PQgetResult would return nothing,
potentially causing the calling application to enter a busy loop.
Fix by making the SYNC queue element a barrier that can only be consumed
when a SYNC message is received.
Backpatch to 14.
Reported by: Иван Трофимов (Ivan Trofimov) <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/interfaces/libpq/libpq-int.h')
-rw-r--r-- | src/interfaces/libpq/libpq-int.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h index 22bc682ffce..7888199b0d9 100644 --- a/src/interfaces/libpq/libpq-int.h +++ b/src/interfaces/libpq/libpq-int.h @@ -698,7 +698,8 @@ extern void pqSaveMessageField(PGresult *res, char code, extern void pqSaveParameterStatus(PGconn *conn, const char *name, const char *value); extern int pqRowProcessor(PGconn *conn, const char **errmsgp); -extern void pqCommandQueueAdvance(PGconn *conn); +extern void pqCommandQueueAdvance(PGconn *conn, bool isReadyForQuery, + bool gotSync); extern int PQsendQueryContinue(PGconn *conn, const char *query); /* === in fe-protocol3.c === */ |