]> git.ipfire.org Git - thirdparty/psycopg.git/commit
fix: also sync nested pipeline when a transaction is active
authorDenis Laxalde <denis@laxalde.org>
Thu, 15 Sep 2022 16:28:21 +0000 (18:28 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 16 Sep 2022 22:43:45 +0000 (23:43 +0100)
commitd41d8fc6a09718babb570ec7a891ef047bd6121c
tree363f2cb9e774e49515489f54318e8e8447309e02
parent052534ff0c8d947ae4d3b97a655c3d643ff8873a
fix: also sync nested pipeline when a transaction is active

Upon enter, transaction() checks the in-transaction status to determine
if a BEGIN (when IDLE) or a SAVEPOINT (otherwise) should be inserted.
However, in pipeline mode, if the pipeline is in "implicit transaction"
(i.e. it has no active BEGIN) and statements have been sent, the
in-transaction status might be ACTIVE if those statements have not yet
completed (typically, when results have not been fetched).

By issuing a sync() before entering a nested pipeline (which will happen
when entering transaction(), if already within a pipeline), we force
completion of those statements, and thus get a predictable
in-transaction status before entering the transaction() block.

Closes #374.
docs/news.rst
psycopg/psycopg/_pipeline.py
tests/test_pipeline.py
tests/test_pipeline_async.py