diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index eea0237c3a5..00ccefbac0e 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -1810,8 +1810,8 @@ PQgetResult(PGconn *conn) * EOF indication. We expect therefore that this won't result in any * undue delay in reporting a previous write failure.) */ - if (flushResult || - pqWait(true, false, conn) || + if (flushResult || (zpq_buffered_rx(conn->zstream) == 0 && + pqWait(true, false, conn)) || pqReadData(conn) < 0) { /* diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c index 4a38eed2c70..fc77a5a2e62 100644 --- a/src/interfaces/libpq/fe-protocol3.c +++ b/src/interfaces/libpq/fe-protocol3.c @@ -1679,7 +1679,7 @@ pqGetCopyData3(PGconn *conn, char **buffer, int async) if (async) return 0; /* Need to load more data */ - if (pqWait(true, false, conn) || + if ((zpq_buffered_rx(conn->zstream) == 0 && pqWait(true, false, conn)) || pqReadData(conn) < 0) return -2; continue; @@ -1737,7 +1737,7 @@ pqGetline3(PGconn *conn, char *s, int maxlen) while ((status = PQgetlineAsync(conn, s, maxlen - 1)) == 0) { /* need to load more data */ - if (pqWait(true, false, conn) || + if ((zpq_buffered_rx(conn->zstream) == 0 && pqWait(true, false, conn)) || pqReadData(conn) < 0) { *s = '\0'; @@ -1975,7 +1975,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid, if (needInput) { /* Wait for some data to arrive (or for the channel to close) */ - if (pqWait(true, false, conn) || + if ((zpq_buffered_rx(conn->zstream) == 0 && pqWait(true, false, conn)) || pqReadData(conn) < 0) break; }