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

Method Exec

batch.go:130–171  ·  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

128
129// Exec reads the results from the next query in the batch as if the query has been sent with Exec.
130func (br *batchResults) Exec() (pgconn.CommandTag, error) {
131 if br.err != nil {
132 return pgconn.CommandTag{}, br.err
133 }
134 if br.closed {
135 return pgconn.CommandTag{}, fmt.Errorf("batch already closed")
136 }
137
138 query, arguments, _ := br.nextQueryAndArgs()
139
140 if !br.mrr.NextResult() {
141 err := br.mrr.Close()
142 if err == nil {
143 err = errors.New("no more results in batch")
144 }
145 if br.conn.batchTracer != nil {
146 br.conn.batchTracer.TraceBatchQuery(br.ctx, br.conn, TraceBatchQueryData{
147 SQL: query,
148 Args: arguments,
149 Err: err,
150 })
151 }
152 return pgconn.CommandTag{}, err
153 }
154
155 commandTag, err := br.mrr.ResultReader().Close()
156 if err != nil {
157 br.err = err
158 br.mrr.Close()
159 }
160
161 if br.conn.batchTracer != nil {
162 br.conn.batchTracer.TraceBatchQuery(br.ctx, br.conn, TraceBatchQueryData{
163 SQL: query,
164 Args: arguments,
165 CommandTag: commandTag,
166 Err: br.err,
167 })
168 }
169
170 return commandTag, br.err
171}
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) {

Callers 1

CloseMethod · 0.95

Calls 5

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

Tested by

no test coverage detected