MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / cdb2_get_effects

Function cdb2_get_effects

cdb2api/cdb2api.c:3495–3546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3493}
3494
3495int cdb2_get_effects(cdb2_hndl_tp *hndl, cdb2_effects_tp *effects)
3496{
3497 int rc = 0;
3498
3499 if (hndl->fdb_hndl)
3500 hndl = hndl->fdb_hndl;
3501
3502 while (cdb2_next_record_int(hndl, 0) == CDB2_OK)
3503 ;
3504
3505 if (hndl->lastresponse == NULL) {
3506 int lrc = cdb2_effects_request(hndl);
3507 if (lrc) {
3508 rc = -1;
3509 } else if (hndl->firstresponse && hndl->firstresponse->effects) {
3510 effects->num_affected = hndl->firstresponse->effects->num_affected;
3511 effects->num_selected = hndl->firstresponse->effects->num_selected;
3512 effects->num_updated = hndl->firstresponse->effects->num_updated;
3513 effects->num_deleted = hndl->firstresponse->effects->num_deleted;
3514 effects->num_inserted = hndl->firstresponse->effects->num_inserted;
3515 cdb2__sqlresponse__free_unpacked(hndl->firstresponse, NULL);
3516 free((void *)hndl->first_buf);
3517 hndl->first_buf = NULL;
3518 hndl->firstresponse = NULL;
3519 rc = 0;
3520 } else {
3521 rc = -1;
3522 }
3523 } else if (hndl->lastresponse->effects) {
3524 effects->num_affected = hndl->lastresponse->effects->num_affected;
3525 effects->num_selected = hndl->lastresponse->effects->num_selected;
3526 effects->num_updated = hndl->lastresponse->effects->num_updated;
3527 effects->num_deleted = hndl->lastresponse->effects->num_deleted;
3528 effects->num_inserted = hndl->lastresponse->effects->num_inserted;
3529 rc = 0;
3530 } else {
3531 rc = -1;
3532 }
3533
3534 if (log_calls) {
3535 fprintf(stderr, "%p> cdb_get_effects(%p) = %d", (void *)pthread_self(),
3536 hndl, rc);
3537 if (rc == 0)
3538 fprintf(stderr, " => affected %d, selected %d, updated %d, deleted "
3539 "%d, inserted %d\n",
3540 effects->num_affected, effects->num_selected,
3541 effects->num_updated, effects->num_deleted,
3542 effects->num_inserted);
3543 }
3544
3545 return rc;
3546}
3547
3548static void free_events(cdb2_hndl_tp *hndl)
3549{

Callers 11

run_statementFunction · 0.85
update_intFunction · 0.85
prepare_select_bugFunction · 0.85
prepare_select_testFunction · 0.85
clearFunction · 0.85
updateFunction · 0.85
mainFunction · 0.85
run_statementFunction · 0.85
run_statement_get_rtnFunction · 0.85
clnt_run_queryFunction · 0.85
tclcdb2ObjCmdFunction · 0.85

Calls 3

cdb2_next_record_intFunction · 0.85
cdb2_effects_requestFunction · 0.85
freeFunction · 0.85

Tested by 1

run_statementFunction · 0.68