| 503 | } |
| 504 | |
| 505 | int64_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 | |
| 537 | void dump_param(cson_value *param) { |
| 538 | char *name; |
no test coverage detected