updated DeallocateAll to also reset client-side statement and description cache
This commit is contained in:
committed by
Jack Christensen
parent
c94c47f584
commit
3520c2ea43
@@ -326,9 +326,15 @@ func (c *Conn) Deallocate(ctx context.Context, name string) error {
|
|||||||
return err
|
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 {
|
func (c *Conn) DeallocateAll(ctx context.Context, name string) error {
|
||||||
c.preparedStatements = map[string]*pgconn.StatementDescription{}
|
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()
|
_, err := c.pgConn.Exec(ctx, "deallocate all").ReadAll()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user