]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
fix: sync pipeline after tpc_prepare()
authorDenis Laxalde <denis@laxalde.org>
Tue, 10 May 2022 19:24:12 +0000 (21:24 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 19 May 2022 16:56:39 +0000 (18:56 +0200)
This is to get the NotSupported raised directly when calling
tpc_prepare() as expected in test_tpc_disabled().

psycopg/psycopg/connection.py
tests/test_tpc.py
tests/test_tpc_async.py

index 997af7b66b2de05958885924e43228d84ccf3d49..41f5c2920fb80264b725e413eff65085b5336f00 100644 (file)
@@ -613,6 +613,8 @@ class BaseConnection(Generic[Row]):
         xid = self._tpc[0]
         self._tpc = (xid, True)
         yield from self._exec_command(SQL("PREPARE TRANSACTION {}").format(str(xid)))
+        if self._pipeline:
+            yield from self._pipeline._sync_gen()
 
     def _tpc_finish_gen(self, action: str, xid: Union[Xid, str, None]) -> PQGen[None]:
         fname = f"tpc_{action}()"
index f964bb4ba78227866f2aa9a6198215f9cc03b4c7..fa2241bd372bf59e7558804e8ba0d88fea8808e1 100644 (file)
@@ -4,7 +4,7 @@ import psycopg
 from psycopg.pq import TransactionStatus
 
 
-def test_tpc_disabled(conn):
+def test_tpc_disabled(conn, pipeline):
     val = int(conn.execute("show max_prepared_transactions").fetchone()[0])
     if val:
         pytest.skip("prepared transactions enabled")
index e3e5dcf64f62d820b9018dee317e114e2abf3c97..30ca0ed4e5b3ccc90fabb3d6bc883c4c7c58e791 100644 (file)
@@ -6,7 +6,7 @@ from psycopg.pq import TransactionStatus
 pytestmark = [pytest.mark.asyncio]
 
 
-async def test_tpc_disabled(aconn):
+async def test_tpc_disabled(aconn, apipeline):
     cur = await aconn.execute("show max_prepared_transactions")
     val = int((await cur.fetchone())[0])
     if val: