From e16bfa9af53e1ba5c007bdd7cce89cd5e1455518 Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Thu, 19 Sep 2019 22:46:43 -0500 Subject: [PATCH] Add docs regarding closing BatchResults --- batch.go | 5 +++-- conn.go | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/batch.go b/batch.go index 53719def..2f85b852 100644 --- a/batch.go +++ b/batch.go @@ -36,8 +36,9 @@ type BatchResults interface { // QueryRow reads the results from the next query in the batch as if the query has been sent with Conn.QueryRow. QueryRow() Row - // Close closes the batch operation. Any error that occurred during a batch operation may have made it impossible to - // resyncronize the connection with the server. In this case the underlying connection will have been closed. + // Close closes the batch operation. This must be called before the underlying connection can be used again. Any error + // that occurred during a batch operation may have made it impossible to resyncronize the connection with the server. + // In this case the underlying connection will have been closed. Close() error } diff --git a/conn.go b/conn.go index d0450da8..5515dddc 100644 --- a/conn.go +++ b/conn.go @@ -685,7 +685,8 @@ func (c *Conn) QueryRow(ctx context.Context, sql string, args ...interface{}) Ro } // SendBatch sends all queued queries to the server at once. All queries are run in an implicit transaction unless -// explicit transaction control statements are executed. +// explicit transaction control statements are executed. The returned BatchResults must be closed before the connection +// is used again. func (c *Conn) SendBatch(ctx context.Context, b *Batch) BatchResults { distinctUnpreparedQueries := map[string]struct{}{}