From: Daniele Varrazzo Date: Tue, 16 Nov 2021 14:19:40 +0000 (+0100) Subject: Drop PrepareManger.maintain() X-Git-Tag: pool-3.1~98^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d8a30df601e9d198891c59c6ab96fdc790b63a6;p=thirdparty%2Fpsycopg.git Drop PrepareManger.maintain() --- diff --git a/psycopg/psycopg/_preparing.py b/psycopg/psycopg/_preparing.py index 4ebca8d4a..34ad77ea2 100644 --- a/psycopg/psycopg/_preparing.py +++ b/psycopg/psycopg/_preparing.py @@ -182,20 +182,6 @@ class PrepareManager: return None return self._rotate() - def maintain( - self, - query: PostgresQuery, - results: Sequence["PGresult"], - prep: Prepare, - name: bytes, - ) -> Optional[bytes]: - """Maintain the cache of the prepared statements.""" - key = self.maybe_add_to_cache(query, prep, name) - if key is None: - return None - - return self.validate(key, prep, name, results) - def clear(self) -> Optional[bytes]: if self._prepared_idx: self._prepared.clear() diff --git a/psycopg/psycopg/cursor.py b/psycopg/psycopg/cursor.py index b13efd052..f4cafe387 100644 --- a/psycopg/psycopg/cursor.py +++ b/psycopg/psycopg/cursor.py @@ -258,9 +258,11 @@ class BaseCursor(Generic[ConnectionType, Row]): # Update the prepare state of the query. # If an operation requires to flush our prepared statements cache, do it. - cmd = self._conn._prepared.maintain(pgq, results, prep, name) - if cmd: - yield from self._conn._exec_command(cmd) + key = self._conn._prepared.maybe_add_to_cache(pgq, prep, name) + if key is not None: + cmd = self._conn._prepared.validate(key, prep, name, results) + if cmd: + yield from self._conn._exec_command(cmd) return results