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

Method Query

batch.go:174–212  ·  view source on GitHub ↗

Query reads the results from the next query in the batch as if the query has been sent with Query.

()

Source from the content-addressed store, hash-verified

172
173// Query reads the results from the next query in the batch as if the query has been sent with Query.
174func (br *batchResults) Query() (Rows, error) {
175 query, arguments, ok := br.nextQueryAndArgs()
176 if !ok {
177 query = "batch query"
178 }
179
180 if br.err != nil {
181 return &baseRows{err: br.err, closed: true}, br.err
182 }
183
184 if br.closed {
185 alreadyClosedErr := fmt.Errorf("batch already closed")
186 return &baseRows{err: alreadyClosedErr, closed: true}, alreadyClosedErr
187 }
188
189 rows := br.conn.getRows(br.ctx, query, arguments)
190 rows.batchTracer = br.conn.batchTracer
191
192 if !br.mrr.NextResult() {
193 rows.err = br.mrr.Close()
194 if rows.err == nil {
195 rows.err = errors.New("no more results in batch")
196 }
197 rows.closed = true
198
199 if br.conn.batchTracer != nil {
200 br.conn.batchTracer.TraceBatchQuery(br.ctx, br.conn, TraceBatchQueryData{
201 SQL: query,
202 Args: arguments,
203 Err: rows.err,
204 })
205 }
206
207 return rows, rows.err
208 }
209
210 rows.resultReader = br.mrr.ResultReader()
211 return rows, nil
212}
213
214// QueryRow reads the results from the next query in the batch as if the query has been sent with QueryRow.
215func (br *batchResults) QueryRow() Row {

Callers 1

QueryRowMethod · 0.95

Calls 6

nextQueryAndArgsMethod · 0.95
getRowsMethod · 0.80
NextResultMethod · 0.80
ResultReaderMethod · 0.80
CloseMethod · 0.65
TraceBatchQueryMethod · 0.65

Tested by

no test coverage detected