From 1beaa654da61ee66857a3c5125682b629f62fdf9 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Fri, 9 Jul 2021 15:57:59 -0400 Subject: libpq: Fix sending queries in pipeline aborted state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When sending queries in pipeline mode, we were careless about leaving the connection in the right state so that PQgetResult would behave correctly; trying to read further results after sending a query after having read a result with an error would sometimes hang. Fix by ensuring internal libpq state is changed properly. All the state changes were being done by the callers of pqAppendCmdQueueEntry(); it would have become too repetitious to have this logic in each of them, so instead put it all in that function and relieve callers of the responsibility. Add a test to verify this case. Without the code fix, this new test hangs sometimes. Also, document that PQisBusy() would return false when no queries are pending result. This is not intuitively obvious, and NULL would be obtained by calling PQgetResult() at that point, which is confusing. Wording by Boris Kolpackov. In passing, fix bogus use of "false" to mean "0", per Ranier Vilela. Backpatch to 14. Author: Álvaro Herrera Reported-by: Boris Kolpackov Discussion: https://postgr.es/m/boris.20210624103805@codesynthesis.com --- doc/src/sgml/libpq.sgml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'doc/src') diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 59e3e678f9e..2e4f615a659 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -5171,7 +5171,10 @@ int PQflush(PGconn *conn); PQisBusy, PQconsumeInput, etc - operate as normal when processing pipeline results. + operate as normal when processing pipeline results. In particular, + a call to PQisBusy in the middle of a pipeline + returns 0 if the results for all the queries issued so far have been + consumed. -- cgit v1.2.3