From 8e9309ccea5d452614f584307a6103ca3f04a799 Mon Sep 17 00:00:00 2001 From: Floris van Nee Date: Sat, 26 Nov 2022 09:42:28 +0100 Subject: [PATCH] Do not try to cleanup statements This supports a case where we prepare an unnamed statement to inspect the return types. The statement should not be cleaned up afterwards because it is automatically cleaned up by Postgres --- asyncpg/connection.py | 1 + 1 file changed, 1 insertion(+) diff --git a/asyncpg/connection.py b/asyncpg/connection.py index 365ab416..73cb6e66 100644 --- a/asyncpg/connection.py +++ b/asyncpg/connection.py @@ -1416,6 +1416,7 @@ def _mark_stmts_as_closed(self): def _maybe_gc_stmt(self, stmt): if ( stmt.refs == 0 + and stmt.name and not self._stmt_cache.has( (stmt.query, stmt.record_class, stmt.ignore_custom_codec) )