Exec reads the results from the next query in the batch as if the query has been sent with Exec.
()
| 128 | |
| 129 | // Exec reads the results from the next query in the batch as if the query has been sent with Exec. |
| 130 | func (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. |
| 174 | func (br *batchResults) Query() (Rows, error) { |
no test coverage detected