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

Function last_cost

tools/cdb2_sqlreplay/cdb2_sqlreplay.cpp:505–535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

503}
504
505int64_t last_cost(cdb2_hndl_tp *db) {
506 int64_t cost = 0;
507 cdb2_clearbindings(db);
508
509 int rc = cdb2_run_statement(db, "select comdb2_prevquerycost()");
510 if (rc) {
511 fprintf(stderr, "can't get cost? run rc %d %s\n", rc, cdb2_errstr(db));
512 had_errors = 1;
513 return 0;
514 }
515
516 rc = cdb2_next_record(db);
517 while (rc == CDB2_OK) {
518 char *s = (char*) cdb2_column_value(db, 0);
519 if (s) {
520 // This is not pretty but we don't expose a nicer way to do this.
521 char *coststr = strstr(s, "Cost: ");
522 if (coststr) {
523 coststr += 6;
524 cost = std::strtol(coststr, nullptr, 10);
525 }
526 }
527 rc = cdb2_next_record(db);
528 }
529 if (rc != CDB2_OK_DONE) {
530 fprintf(stderr, "last cost next rc %d %s\n", rc, cdb2_errstr(db));
531 had_errors = 1;
532 }
533
534 return cost;
535}
536
537void dump_param(cson_value *param) {
538 char *name;

Callers 1

replayFunction · 0.85

Calls 5

cdb2_clearbindingsFunction · 0.85
cdb2_run_statementFunction · 0.85
cdb2_errstrFunction · 0.85
cdb2_next_recordFunction · 0.85
cdb2_column_valueFunction · 0.85

Tested by

no test coverage detected