diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/psql/common.c | 4 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 5 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-exec.c | 3 | ||||
-rw-r--r-- | src/test/examples/testlibpq2.c | 1 |
4 files changed, 10 insertions, 3 deletions
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index c7f5206fee4..475587c04ad 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -606,7 +606,8 @@ PrintNotifications(void) { PGnotify *notify; - while ((notify = PQnotifies(pset.db))) + PQconsumeInput(pset.db); + while ((notify = PQnotifies(pset.db)) != NULL) { /* for backward compatibility, only show payload if nonempty */ if (notify->extra[0]) @@ -617,6 +618,7 @@ PrintNotifications(void) notify->relname, notify->be_pid); fflush(pset.queryFout); PQfreemem(notify); + PQconsumeInput(pset.db); } } diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index 5b09233810d..5b32e7cbcb2 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -1730,12 +1730,13 @@ ecpg_process_output(struct statement * stmt, bool clear_result) } /* check for asynchronous returns */ - notify = PQnotifies(stmt->connection->connection); - if (notify) + PQconsumeInput(stmt->connection->connection); + while ((notify = PQnotifies(stmt->connection->connection)) != NULL) { ecpg_log("ecpg_process_output on line %d: asynchronous notification of \"%s\" from backend PID %d received\n", stmt->lineno, notify->relname, notify->be_pid); PQfreemem(notify); + PQconsumeInput(stmt->connection->connection); } return status; diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index ad108f5b0f0..a74090faaeb 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -2234,6 +2234,9 @@ sendFailed: * no unhandled async notification from the backend * * the CALLER is responsible for FREE'ing the structure returned + * + * Note that this function does not read any new data from the socket; + * so usually, caller should call PQconsumeInput() first. */ PGnotify * PQnotifies(PGconn *conn) diff --git a/src/test/examples/testlibpq2.c b/src/test/examples/testlibpq2.c index 62ecd68b55e..6cdf8c8631b 100644 --- a/src/test/examples/testlibpq2.c +++ b/src/test/examples/testlibpq2.c @@ -140,6 +140,7 @@ main(int argc, char **argv) notify->relname, notify->be_pid); PQfreemem(notify); nnotifies++; + PQconsumeInput(conn); } } |