]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Drop PrepareManger.maintain()
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 16 Nov 2021 14:19:40 +0000 (15:19 +0100)
committerDenis Laxalde <denis.laxalde@dalibo.com>
Mon, 29 Nov 2021 08:50:50 +0000 (09:50 +0100)
psycopg/psycopg/_preparing.py
psycopg/psycopg/cursor.py

index 4ebca8d4a1772bc512cedc3bb6a9b6054c5438b6..34ad77ea243b60b99c004881dd9fc65b1cd75fe1 100644 (file)
@@ -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()
index b13efd0520568ffcd93c2d7d8d06d54c33b4d272..f4cafe387d9e50ea88cfdbbce6b39bd3749923c1 100644 (file)
@@ -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