From 3520c2ea435f07db44d3fc07da470d277f4dde6c Mon Sep 17 00:00:00 2001 From: Bodo Kaiser Date: Sat, 12 Nov 2022 17:04:13 +0100 Subject: [PATCH] updated DeallocateAll to also reset client-side statement and description cache --- conn.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/conn.go b/conn.go index 7dee1eec..91b917cb 100644 --- a/conn.go +++ b/conn.go @@ -326,9 +326,15 @@ func (c *Conn) Deallocate(ctx context.Context, name string) error { return err } -// Deallocate all released prepared statements +// DeallocateAll releases all previously prepared statements from the server and client, where it also resets the statement and description cache. func (c *Conn) DeallocateAll(ctx context.Context, name string) error { c.preparedStatements = map[string]*pgconn.StatementDescription{} + if c.config.StatementCacheCapacity > 0 { + c.statementCache = stmtcache.NewLRUCache(c.config.StatementCacheCapacity) + } + if c.config.DescriptionCacheCapacity > 0 { + c.descriptionCache = stmtcache.NewLRUCache(c.config.DescriptionCacheCapacity) + } _, err := c.pgConn.Exec(ctx, "deallocate all").ReadAll() return err }