Add docs regarding closing BatchResults

pull/620/head
Jack Christensen 2019-09-19 22:46:43 -05:00
parent 9d3a4b5736
commit e16bfa9af5
2 changed files with 5 additions and 3 deletions

View File

@ -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
}

View File

@ -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{}{}