| 3245 | |
| 3246 | |
| 3247 | IBatchCompletionState* Batch::execute(CheckStatusWrapper* status, ITransaction* apiTra) |
| 3248 | { |
| 3249 | try |
| 3250 | { |
| 3251 | // Check and validate handles, etc. |
| 3252 | |
| 3253 | if (!stmt) |
| 3254 | { |
| 3255 | Arg::Gds(isc_bad_req_handle).raise(); |
| 3256 | } |
| 3257 | |
| 3258 | Rsr* statement = stmt->getStatement(); |
| 3259 | CHECK_HANDLE(statement, isc_bad_req_handle); |
| 3260 | |
| 3261 | Rdb* rdb = statement->rsr_rdb; |
| 3262 | CHECK_HANDLE(rdb, isc_bad_db_handle); |
| 3263 | |
| 3264 | rem_port* port = rdb->rdb_port; |
| 3265 | RefMutexGuard portGuard(*port->port_sync, FB_FUNCTION); |
| 3266 | |
| 3267 | Rtr* transaction = NULL; |
| 3268 | Transaction* rt = stmt->getAttachment()->remoteTransactionInterface(apiTra); |
| 3269 | if (rt) |
| 3270 | { |
| 3271 | transaction = rt->getTransaction(); |
| 3272 | CHECK_HANDLE(transaction, isc_bad_trans_handle); |
| 3273 | } |
| 3274 | |
| 3275 | // Sanity checks complete - flash data in buffers |
| 3276 | flashBatch(); |
| 3277 | |
| 3278 | // Prepare and send execute packet |
| 3279 | PACKET* packet = &rdb->rdb_packet; |
| 3280 | packet->p_operation = op_batch_exec; |
| 3281 | P_BATCH_EXEC* batch = &packet->p_batch_exec; |
| 3282 | batch->p_batch_statement = statement->rsr_id; |
| 3283 | batch->p_batch_transaction = transaction->rtr_id; |
| 3284 | send_packet(port, packet); |
| 3285 | |
| 3286 | statement->rsr_batch_size = alignedSize; |
| 3287 | AutoPtr<BatchCompletionState, SimpleDispose> |
| 3288 | cs(FB_NEW BatchCompletionState(flags & (1 << IBatch::TAG_RECORD_COUNTS), 256)); |
| 3289 | statement->rsr_batch_cs = cs; |
| 3290 | receive_packet(port, packet); |
| 3291 | statement->rsr_batch_cs = nullptr; |
| 3292 | |
| 3293 | if (packet->p_operation == op_batch_cs) |
| 3294 | { |
| 3295 | // when working with 4.0.0 server we could not raise it in advance... |
| 3296 | statement->clearException(); |
| 3297 | |
| 3298 | return cs.release(); |
| 3299 | } |
| 3300 | |
| 3301 | REMOTE_check_response(status, rdb, packet); |
| 3302 | } |
| 3303 | catch (const Exception& ex) |
| 3304 | { |
no test coverage detected