From 1d8a30df601e9d198891c59c6ab96fdc790b63a6 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Tue, 16 Nov 2021 15:19:40 +0100 Subject: [PATCH] Drop PrepareManger.maintain() --- psycopg/psycopg/_preparing.py | 14 -------------- psycopg/psycopg/cursor.py | 8 +++++--- 2 files changed, 5 insertions(+), 17 deletions(-) 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 -- 2.47.2