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

Method Exec

batch.go:292–332  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

290
291// Exec reads the results from the next query in the batch as if the query has been sent with Exec.
292func (br *pipelineBatchResults) Exec() (pgconn.CommandTag, error) {
293 if br.err != nil {
294 return pgconn.CommandTag{}, br.err
295 }
296 if br.closed {
297 return pgconn.CommandTag{}, fmt.Errorf("batch already closed")
298 }
299 if br.lastRows != nil && br.lastRows.err != nil {
300 br.err = br.lastRows.err
301 return pgconn.CommandTag{}, br.err
302 }
303
304 query, arguments, err := br.nextQueryAndArgs()
305 if err != nil {
306 return pgconn.CommandTag{}, err
307 }
308
309 results, err := br.pipeline.GetResults()
310 if err != nil {
311 br.err = err
312 return pgconn.CommandTag{}, br.err
313 }
314 var commandTag pgconn.CommandTag
315 switch results := results.(type) {
316 case *pgconn.ResultReader:
317 commandTag, br.err = results.Close()
318 default:
319 return pgconn.CommandTag{}, fmt.Errorf("unexpected pipeline result: %T", results)
320 }
321
322 if br.conn.batchTracer != nil {
323 br.conn.batchTracer.TraceBatchQuery(br.ctx, br.conn, TraceBatchQueryData{
324 SQL: query,
325 Args: arguments,
326 CommandTag: commandTag,
327 Err: br.err,
328 })
329 }
330
331 return commandTag, br.err
332}
333
334// Query reads the results from the next query in the batch as if the query has been sent with Query.
335func (br *pipelineBatchResults) Query() (Rows, error) {

Callers 1

CloseMethod · 0.95

Calls 4

nextQueryAndArgsMethod · 0.95
GetResultsMethod · 0.80
CloseMethod · 0.65
TraceBatchQueryMethod · 0.65

Tested by

no test coverage detected