You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b653965
Browse filesBrowse the repository at this point in the historyBrowse files
The :batchexec, :batchmany and :batchone sections listed the batch object's
methods but never said what the callback receives, what its int argument
means, what Close does to statements that have not run yet, or when Close is
even needed. Issue #4631 reports exactly this: readers cannot tell what to do
with the returned batch object.
Add a 'Using the batch object' section that documents the callback contract
and Close semantics, and point each batch annotation at it:
- the callback is invoked once per queued statement, in order, and the int is
the statement's 0-based position in the batch
- a failing statement does not stop iteration; errors must be handled inside
the callback
- Close before or during iteration skips the remaining statements and
delivers ErrBatchAlreadyClosed once per remaining statement
- Close is called automatically when the iteration method returns, so a fully
iterated batch needs no explicit Close
The behaviour described is taken from the generated code itself
(internal/codegen/golang/templates/pgx/batchCode.tmpl and the batch endtoend
golden files), not paraphrased from other docs.
Fixes#4631
0 commit comments