added DeallocateAll to pgx.Conn to clear prepared statement cache
This commit is contained in:
committed by
Jack Christensen
parent
8678ed560f
commit
c94c47f584
@@ -326,6 +326,13 @@ func (c *Conn) Deallocate(ctx context.Context, name string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deallocate all released prepared statements
|
||||||
|
func (c *Conn) DeallocateAll(ctx context.Context, name string) error {
|
||||||
|
c.preparedStatements = map[string]*pgconn.StatementDescription{}
|
||||||
|
_, err := c.pgConn.Exec(ctx, "deallocate all").ReadAll()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Conn) bufferNotifications(_ *pgconn.PgConn, n *pgconn.Notification) {
|
func (c *Conn) bufferNotifications(_ *pgconn.PgConn, n *pgconn.Notification) {
|
||||||
c.notifications = append(c.notifications, n)
|
c.notifications = append(c.notifications, n)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -424,7 +424,7 @@ func TestPrepare(t *testing.T) {
|
|||||||
t.Errorf("Prepared statement did not return expected value: %v", s)
|
t.Errorf("Prepared statement did not return expected value: %v", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = conn.Deallocate(context.Background(), "test")
|
err = conn.DeallocateAll(context.Background(), "test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("conn.Deallocate failed: %v", err)
|
t.Errorf("conn.Deallocate failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user