diff --git a/conn.go b/conn.go index 3ee067df..40df37c5 100644 --- a/conn.go +++ b/conn.go @@ -282,14 +282,9 @@ func (c *Conn) PrepareEx(ctx context.Context, name, sql string, opts *PrepareExO } // Deallocate released a prepared statement -func (c *Conn) Deallocate(name string) error { - return c.deallocateContext(context.Background(), name) -} - -// TODO - consider making this public -func (c *Conn) deallocateContext(ctx context.Context, name string) (err error) { +func (c *Conn) Deallocate(ctx context.Context, name string) error { delete(c.preparedStatements, name) - _, err = c.pgConn.Exec(ctx, "deallocate "+quoteIdentifier(name)).ReadAll() + _, err := c.pgConn.Exec(ctx, "deallocate "+quoteIdentifier(name)).ReadAll() return err } diff --git a/conn_test.go b/conn_test.go index ffeee1bf..93c4ad42 100644 --- a/conn_test.go +++ b/conn_test.go @@ -297,7 +297,7 @@ func TestPrepare(t *testing.T) { t.Errorf("Prepared statement did not return expected value: %v", s) } - err = conn.Deallocate("test") + err = conn.Deallocate(context.Background(), "test") if err != nil { t.Errorf("conn.Deallocate failed: %v", err) } @@ -321,7 +321,7 @@ func TestPrepare(t *testing.T) { t.Errorf("Prepared statement did not return expected value: %v", s) } - err = conn.Deallocate("test") + err = conn.Deallocate(context.Background(), "test") if err != nil { t.Errorf("conn.Deallocate failed: %v", err) } @@ -392,7 +392,7 @@ func TestPrepareEx(t *testing.T) { t.Errorf("Prepared statement did not return expected value: %v", s) } - err = conn.Deallocate("test") + err = conn.Deallocate(context.Background(), "test") if err != nil { t.Errorf("conn.Deallocate failed: %v", err) } diff --git a/stdlib/sql.go b/stdlib/sql.go index eaf1caa7..cb4b5195 100644 --- a/stdlib/sql.go +++ b/stdlib/sql.go @@ -315,7 +315,7 @@ type Stmt struct { } func (s *Stmt) Close() error { - return s.conn.conn.Deallocate(s.ps.Name) + return s.conn.conn.Deallocate(context.Background(), s.ps.Name) } func (s *Stmt) NumInput() int {