]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Return PIPELINE_SYNC result alone in generators.fetch_many()
authorDenis Laxalde <denis.laxalde@dalibo.com>
Tue, 30 Nov 2021 14:47:59 +0000 (15:47 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 2 Apr 2022 23:17:57 +0000 (01:17 +0200)
psycopg/psycopg/generators.py
psycopg_c/psycopg_c/_psycopg/generators.pyx

index 76583bbf367d9e225f288b790a0a6217d59b1d7c..2a4aeaf5df2d3a024f4bff689b151a6ad9678cf3 100644 (file)
@@ -125,6 +125,12 @@ def fetch_many(pgconn: PGconn) -> PQGen[List[PGresult]]:
             # for every request so let's break the endless loop.
             break
 
+        if res.status == pq.ExecStatus.PIPELINE_SYNC:
+            # PIPELINE_SYNC is not followed by a NULL, but we return it alone
+            # similarly to other result sets.
+            assert len(results) == 1, results
+            break
+
     return results
 
 
index 239494974ddf74d8fd74ce2091a9f8b713bbec16..86461024e30f784bc5d68431702a899aa261b635 100644 (file)
@@ -137,6 +137,12 @@ def fetch_many(pq.PGconn pgconn) -> PQGen[List[PGresult]]:
             # for every request so let's break the endless loop.
             break
 
+        if status == libpq.PGRES_PIPELINE_SYNC:
+            # PIPELINE_SYNC is not followed by a NULL, but we return it alone
+            # similarly to other result sets.
+            assert len(results) == 1, results
+            break
+
     return results