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

Function main

tools/cdb2_sqlreplay/cdb2_sqlreplay.cpp:1027–1098  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1025}
1026
1027int main(int argc, char **argv) {
1028 char *filename = nullptr;
1029
1030 signal(SIGPIPE, SIG_IGN);
1031
1032 init_handlers();
1033
1034 if (argc < 2) {
1035 usage();
1036 }
1037 argc--;
1038 argv++;
1039 while (argc && argv[0][0] == '-') {
1040 if (strcmp(argv[0], "--diff") == 0)
1041 diffs = true;
1042 else if (strcmp(argv[0], "--verbose") == 0 || strcmp(argv[0], "-v") == 0)
1043 verbose = true;
1044 else if (strcmp(argv[0], "--threshold") == 0) {
1045 argc--;
1046 argv++;
1047 if (argc == 0) {
1048 fprintf(stderr, "--threshold expected an argument");
1049 return 1;
1050 }
1051 threshold_percent = (int) strtol(argv[0], nullptr, 10);
1052 }
1053 else if (strcmp(argv[0], "--stopat") == 0) {
1054 argc--;
1055 argv++;
1056 if (argc == 0) {
1057 fprintf(stderr, "--stopat expected an argument");
1058 return 1;
1059 }
1060 maxevents = (int) strtol(argv[0], nullptr, 10);
1061 }
1062 else {
1063 fprintf(stderr, "Unknown option %s\n", argv[0]);
1064 }
1065 argc--;
1066 argv++;
1067 }
1068 dbname = argv[0];
1069 argc--;
1070 argv++;
1071
1072 /* TODO: tier should be an option */
1073 int rc;
1074 char *conf = getenv("CDB2_CONFIG");
1075 if (conf) {
1076 cdb2_set_comdb2db_config(conf);
1077 rc = cdb2_open(&cdb2h, dbname, "default", 0);
1078 } else {
1079 rc = cdb2_open(&cdb2h, dbname, "local", 0);
1080 }
1081
1082 if (rc) {
1083 std::cerr << "Error: cdb2_open() failed: " << cdb2_errstr(cdb2h) << std::endl;
1084 exit(EXIT_FAILURE);

Callers

nothing calls this directly

Calls 10

init_handlersFunction · 0.85
cdb2_set_comdb2db_configFunction · 0.85
cdb2_openFunction · 0.85
cdb2_errstrFunction · 0.85
exitFunction · 0.85
cdb2_run_statementFunction · 0.85
process_eventsFunction · 0.85
cdb2_closeFunction · 0.85
add_sourceMethod · 0.80
usageFunction · 0.70

Tested by

no test coverage detected