MCPcopy
hub / github.com/jackc/pgx / Close

Method Close

batch.go:222–262  ·  batch.go::batchResults.Close

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.

()

Source from the content-addressed store, hash-verified

220// Close closes the batch operation. Any error that occurred during a batch operation may have made it impossible to
221// resyncronize the connection with the server. In this case the underlying connection will have been closed.
222func (br *batchResults) Close() error {
223 defer func() {
224 if !br.endTraced {
225 if br.conn != nil && br.conn.batchTracer != nil {
226 br.conn.batchTracer.TraceBatchEnd(br.ctx, br.conn, TraceBatchEndData{Err: br.err})
227 }
228 br.endTraced = true
229 }
230
231 invalidateCachesOnBatchResultsError(br.conn, br.b, br.err)
232 }()
233
234 if br.err != nil {
235 return br.err
236 }
237
238 if br.closed {
239 return nil
240 }
241
242 // Read and run fn for all remaining items
243 for br.err == nil && !br.closed && br.b != nil && br.qqIdx < len(br.b.QueuedQueries) {
244 if br.b.QueuedQueries[br.qqIdx].Fn != nil {
245 err := br.b.QueuedQueries[br.qqIdx].Fn(br)
246 if err != nil {
247 br.err = err
248 }
249 } else {
250 br.Exec()
251 }
252 }
253
254 br.closed = true
255
256 err := br.mrr.Close()
257 if br.err == nil {
258 br.err = err
259 }
260
261 return br.err
262}
263
264func (br *batchResults) earlyError() error {
265 return br.err

Callers

nothing calls this directly

Calls 4

ExecMethod · 0.95
TraceBatchEndMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected