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

Function prepare_select_test

tests/tools/insert.c:621–792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

619#define INSERTS_FOR_T1 1000
620
621int prepare_select_test(void)
622{
623 uint8_t *select_array;
624 cdb2_hndl_tp *db;
625 int rc;
626
627 select_array = (uint8_t *)calloc(sizeof(uint8_t), select_records + 1);
628 rc = cdb2_open(&db, dbname, cltype, 0);
629 cdb2_hndl_set_max_retries(db, max_retries);
630 if (debug_trace) {
631 cdb2_set_debug_trace(db);
632 }
633
634 rc = cdb2_run_statement(db, "set hasql on");
635
636 if (rc) {
637 tdprintf(stderr, db, __func__, __LINE__, "%s line %d: run rc %d %s\n",
638 __func__, __LINE__, rc, cdb2_errstr(db));
639 if (exit_at_failure) myexit(__func__, __LINE__, 1);
640 return rc;
641 }
642
643 rc = cdb2_run_statement(db, "set transaction serializable");
644 if (rc) {
645 tdprintf(stderr, db, __func__, __LINE__, "%s line %d: run rc %d %s\n",
646 __func__, __LINE__, rc, cdb2_errstr(db));
647 if (exit_at_failure) myexit(__func__, __LINE__, 1);
648 return rc;
649 }
650
651 int iteration = 0;
652 cdb2_effects_tp effects;
653 char sql[64];
654
655 // First erase everything larger
656 do {
657 iteration++;
658 rc = cdb2_run_statement(db, "begin");
659 if (rc) {
660 tdprintf(stderr, db, __func__, __LINE__, "XXX %s: begin rc %d %s\n",
661 __func__, rc, cdb2_errstr(db));
662 exit(1);
663 }
664
665 snprintf(sql, sizeof(sql), "delete from t1 where a >= %u limit 1000",
666 select_records);
667
668 rc = cdb2_run_statement(db, sql);
669 if (rc) {
670 tdprintf(stderr, db, __func__, __LINE__,
671 "XXX %s line %d: run rc %d %s\n", __func__, __LINE__, rc,
672 cdb2_errstr(db));
673 exit(1);
674 }
675
676 rc = cdb2_run_statement(db, "commit");
677 if (rc) {
678 tdprintf(stderr, db, __func__, __LINE__,

Callers 1

mainFunction · 0.85

Calls 14

callocFunction · 0.85
cdb2_openFunction · 0.85
cdb2_set_debug_traceFunction · 0.85
cdb2_run_statementFunction · 0.85
tdprintfFunction · 0.85
cdb2_errstrFunction · 0.85
myexitFunction · 0.85
exitFunction · 0.85
cdb2_get_effectsFunction · 0.85
cdb2_next_recordFunction · 0.85
cdb2_column_valueFunction · 0.85

Tested by

no test coverage detected