]> git.ipfire.org Git - thirdparty/psycopg.git/commit
fix: always validate PrepareManager cache in pipeline mode 586/head
authorDenis Laxalde <denis.laxalde@dalibo.com>
Thu, 8 Jun 2023 09:21:42 +0000 (11:21 +0200)
committerDenis Laxalde <denis.laxalde@dalibo.com>
Fri, 9 Jun 2023 13:20:06 +0000 (15:20 +0200)
commitf18bd10ec1d0bc029b4e1950f300c297a590222c
tree3162d39911db3abaebde33cc8faa417179fbd832
parentf26b05873f83536d947bc2e952950ed1ccde066a
fix: always validate PrepareManager cache in pipeline mode

Previously, when processing results in pipeline mode
(BasePipeline._process_results()), we'd run
'cursor._check_results(results)' early before calling
_prepared.validate() with prepared statement information. However, if
this check step fails, for example if the pipeline got aborted due to a
previous error, the latter step (PrepareManager cache validation) was
not run.

We fix this by reversing the logic, and checking results last.

However, this is not enough, because the results processing logic in
BasePipeline._fetch_gen() or _communicate_gen(), which sequentially
walked through fetched results, would typically stop at the first
exception and thus possibly never go through the step of validating
PrepareManager cache if a previous error happened.

We fix that by making sure that *all* results are processed, possibly
capturing the first exception and then re-raising it. In both
_communicate_gen() and _fetch_gen(), we no longer store results in the
'to_process' like, but process then upon reception as this logic is no
longer needed.

Fix #585.
docs/news.rst
psycopg/psycopg/_pipeline.py
tests/test_pipeline.py
tests/test_pipeline_async.py