From: Denis Laxalde Date: Mon, 11 Oct 2021 15:16:39 +0000 (+0200) Subject: Handle pipeline-mode errors when checking results X-Git-Tag: 3.1~146^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05e1819f2a7d8341b4a86b8a9eec74954a21740d;p=thirdparty%2Fpsycopg.git Handle pipeline-mode errors when checking results In BaseCursor._check_result(), we now handle FATAL_ERROR and (the pipeline-mode specific error) PIPELINE_ABORTED in preparation for supporting the pipeline mode where we'd check results upon fetch*() instead of upon execute() currently. Similarly, BaseCursor._raise_for_result() handles PIPELINE_ABORTED result status. --- diff --git a/psycopg/psycopg/cursor.py b/psycopg/psycopg/cursor.py index df2a324dd..e82372dc0 100644 --- a/psycopg/psycopg/cursor.py +++ b/psycopg/psycopg/cursor.py @@ -416,6 +416,8 @@ class BaseCursor(Generic[ConnectionType, Row]): """ if result.status == ExecStatus.FATAL_ERROR: raise e.error_from_result(result, encoding=self._encoding) + elif result.status == ExecStatus.PIPELINE_ABORTED: + raise e.OperationalError("pipeline aborted") elif result.status in self._status_copy: raise e.ProgrammingError( "COPY cannot be used with this method; use copy() insead" @@ -463,6 +465,10 @@ class BaseCursor(Generic[ConnectionType, Row]): res = self.pgresult if not res: raise e.ProgrammingError("no result available") + elif res.status == ExecStatus.FATAL_ERROR: + raise e.error_from_result(res, encoding=pgconn_encoding(self._pgconn)) + elif res.status == ExecStatus.PIPELINE_ABORTED: + raise e.OperationalError("pipeline aborted") elif res.status != ExecStatus.TUPLES_OK: raise e.ProgrammingError("the last operation didn't produce a result")