Skip to content

Commit c64fa0f

Browse files
committed
Document that batched queries should not contain multiple statements
1 parent dced53f commit c64fa0f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

batch.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,13 @@ type Batch struct {
6060
QueuedQueries []*QueuedQuery
6161
}
6262

63-
// Queue queues a query to batch b. query can be an SQL query or the name of a prepared statement.
64-
// The only pgx option argument that is supported is QueryRewriter. Queries are executed using the
65-
// connection's DefaultQueryExecMode.
63+
// Queue queues a query to batch b. query can be an SQL query or the name of a prepared statement. The only pgx option
64+
// argument that is supported is QueryRewriter. Queries are executed using the connection's DefaultQueryExecMode.
65+
//
66+
// While query can contain multiple statements if the connection's DefaultQueryExecMode is QueryModeSimple, this should
67+
// be avoided. QueuedQuery.Fn must not be set as it will only be called for the first query. That is, QueuedQuery.Query,
68+
// QueuedQuery.QueryRow, and QueuedQuery.Exec must not be called. In addition, any error messages or tracing that
69+
// include the current query may reference the wrong query.
6670
func (b *Batch) Queue(query string, arguments ...any) *QueuedQuery {
6771
qq := &QueuedQuery{
6872
SQL: query,

0 commit comments

Comments
 (0)