v2.36.0
What's Changed
Enhancements π
- Add
Close
function to batch interface by @SpencerTorres in #1566
The batch.Close()
function was added to prevent connections from being leaked by the batch interface. In the previous API, it is possible that an early return (due to return err
or some other cause) would cause the connection to be held until the connection timed out.
Here's an example of using this new function:
batch, err := conn.PrepareBatch(ctx, "INSERT INTO function null('x UInt64') VALUES (1)")
if err != nil { . . . }
// This defer call will make sure the batch is absolutely cleaned up before it falls out of scope.
defer batch.Close()
Users should update their code to call this new function. Depending on your insert logic you may be leaking connections if Send
never gets called.
Full Changelog: v2.35.0...v2.36.0