mirror of https://github.com/jackc/pgx.git
Deallocate takes context
parent
1f010f412d
commit
95756b1d7f
9
conn.go
9
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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue