| 3438 | } |
| 3439 | |
| 3440 | int cdb2_next_record(cdb2_hndl_tp *hndl) |
| 3441 | { |
| 3442 | int rc = 0; |
| 3443 | |
| 3444 | void *callbackrc; |
| 3445 | int overwrite_rc = 0; |
| 3446 | cdb2_event *e = NULL; |
| 3447 | |
| 3448 | if (hndl->fdb_hndl) |
| 3449 | hndl = hndl->fdb_hndl; |
| 3450 | |
| 3451 | while ((e = cdb2_next_callback(hndl, CDB2_AT_ENTER_NEXT_RECORD, e)) != |
| 3452 | NULL) { |
| 3453 | callbackrc = cdb2_invoke_callback(hndl, e, 0); |
| 3454 | PROCESS_EVENT_CTRL_BEFORE(hndl, e, rc, callbackrc, overwrite_rc); |
| 3455 | } |
| 3456 | |
| 3457 | if (overwrite_rc) |
| 3458 | goto after_callback; |
| 3459 | |
| 3460 | if (hndl->in_trans && !hndl->read_intrans_results && !hndl->is_read) { |
| 3461 | rc = CDB2_OK_DONE; |
| 3462 | } else if (hndl->lastresponse && hndl->first_record_read == 0) { |
| 3463 | hndl->first_record_read = 1; |
| 3464 | if (hndl->lastresponse->response_type == RESPONSE_TYPE__COLUMN_VALUES || |
| 3465 | hndl->lastresponse->response_type == RESPONSE_TYPE__SQL_ROW) { |
| 3466 | rc = hndl->lastresponse->error_code; |
| 3467 | } else if (hndl->lastresponse->response_type == |
| 3468 | RESPONSE_TYPE__LAST_ROW) { |
| 3469 | if (hndl->num_set_commands) { |
| 3470 | hndl->num_set_commands_sent = hndl->num_set_commands; |
| 3471 | } |
| 3472 | rc = CDB2_OK_DONE; |
| 3473 | } else { |
| 3474 | rc = -1; |
| 3475 | } |
| 3476 | } else { |
| 3477 | rc = cdb2_next_record_int(hndl, 1); |
| 3478 | } |
| 3479 | |
| 3480 | if (log_calls) |
| 3481 | fprintf(stderr, "%p> cdb2_next_record(%p) = %d\n", |
| 3482 | (void *)pthread_self(), hndl, rc); |
| 3483 | |
| 3484 | after_callback: |
| 3485 | while ((e = cdb2_next_callback(hndl, CDB2_AT_EXIT_NEXT_RECORD, e)) != |
| 3486 | NULL) { |
| 3487 | callbackrc = |
| 3488 | cdb2_invoke_callback(hndl, e, 1, CDB2_RETURN_VALUE, (intptr_t)rc); |
| 3489 | PROCESS_EVENT_CTRL_AFTER(hndl, e, rc, callbackrc); |
| 3490 | } |
| 3491 | |
| 3492 | return rc; |
| 3493 | } |
| 3494 | |
| 3495 | int cdb2_get_effects(cdb2_hndl_tp *hndl, cdb2_effects_tp *effects) |
| 3496 | { |