Skip to content

Commit 9bb9a9e

Browse files
committed
docs: clarify pool return timing for queryValues in executeQuery/executeBatch
Update comments to accurately describe the trade-off: pooled queryValues slices are returned after c.exec() completes (full round-trip) rather than immediately after frame serialization. Document that this is intentional — holding slices slightly longer keeps the code simpler and avoids error-prone refactoring of the synchronous c.exec() call.
1 parent da3e671 commit 9bb9a9e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

conn.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,8 @@ func (c *Conn) executeQuery(ctx context.Context, qry *Query) (iter *Iter) {
15721572
}
15731573

15741574
framer, err := c.exec(ctx, frame, qry.trace, qry.GetRequestTimeout())
1575-
// Return pooled queryValues; values were consumed during frame serialization inside c.exec().
1575+
// Return pooled values; consumed by buildFrame at the start of c.exec().
1576+
// Returned after round-trip (not right after serialization) for simplicity.
15761577
putQueryValues(params.values)
15771578
if err != nil {
15781579
return &Iter{err: err}
@@ -1796,7 +1797,8 @@ func (c *Conn) executeBatch(ctx context.Context, batch *Batch) (iter *Iter) {
17961797

17971798
// TODO: should batch support tracing?
17981799
framer, err := c.exec(batch.Context(), req, batch.trace, batch.GetRequestTimeout())
1799-
// Return pooled queryValues; values were consumed during frame serialization inside c.exec().
1800+
// Return pooled values; consumed by buildFrame at the start of c.exec().
1801+
// Returned after round-trip (not right after serialization) for simplicity.
18001802
putBatchQueryValues(req.statements)
18011803
if err != nil {
18021804
return &Iter{err: err}

0 commit comments

Comments
 (0)