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

Function main

tests/tools/cdb2api_caller.cpp:270–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268
269
270int main(int argc, char *argv[])
271{
272 cdb2_hndl_tp *db;
273 if(argc < 2) {
274 fprintf(stderr, "not enough parameters\n");
275 return 1;
276 }
277 char *conf = getenv("CDB2_CONFIG");
278 if (conf)
279 cdb2_set_comdb2db_config(conf);
280 char *host = getenv("CDB2_HOST");
281
282 int rc;
283 if (host)
284 rc = cdb2_open(&db, argv[1], host, CDB2_DIRECT_CPU);
285 else
286 rc = cdb2_open(&db, argv[1], "default", 0);
287 if (rc != 0) {
288 fprintf(stderr, "cdb2_open failed: %d %s\n", rc, cdb2_errstr(db));
289 return rc;
290 }
291
292 const char *table = "t1";
293 if (argc > 2)
294 table = argv[2];
295
296 // insert records
297 for (int j = 1000; j < 2000; j++) {
298 std::ostringstream ss;
299 time_t rawtime;
300 struct tm * timeinfo;
301 char buffer [80];
302
303 time (&rawtime);
304 timeinfo = localtime (&rawtime);
305
306 strftime (buffer,80,"'%FT%T'",timeinfo);
307
308 ss << "insert into " << table << "(alltypes_short, alltypes_u_short, alltypes_int, alltypes_u_int, alltypes_longlong, alltypes_float, alltypes_double, alltypes_byte, alltypes_cstring, alltypes_pstring, alltypes_blob, alltypes_datetime, alltypes_datetimeus, alltypes_vutf8, alltypes_intervalym, alltypes_intervalds, alltypes_intervaldsus, alltypes_decimal32, alltypes_decimal64, alltypes_decimal128) values ( "
309 << ((1-2*(j%2))) << j << ", "
310 << j << ", "
311 << ((1-2*(j%2))) << "0000" << j << ", "
312 << "10000" << j << ", "
313 << ((1-2*(j%2))) << "000000000" << j << ", "
314 << ((1-2*(j%2))) << "00.00" << j << ", "
315 << ((1-2*(j%2))) << "0000" << j << ".0000" << j << ", "
316 << "x'" << (j%2) << (j%3) << (j%4) << (j%5) << (j%2) << (j%3) << (j%4) << (j%5) << (j%2) << (j%3) << (j%4) << (j%5) << (j%2) << (j%3) << (j%4) << (j%5) << "0000000000000000'" << ", "
317 << "'mycstring" << j << "', "
318 << "'mypstring" << j << "', "
319 << "x'" << (j%2) << (j%3) << (j%4) << (j%5) << "', "
320 << buffer << ", "
321 << buffer << ", "
322 << "'myvutf8" << j << "', "
323 << (1-2*(j%2)) << j << ", "
324 << (1-2*(j%2)) << j << ", "
325 << "cast(" << (1-2*(j%2)) << "0000" << j << " as secs) , "
326 << (1-2*(j%2)) << "0000" << j << ", "
327 << (1-2*(j%2)) << "00000000" << j << ", "

Callers

nothing calls this directly

Calls 8

cdb2_set_comdb2db_configFunction · 0.85
cdb2_openFunction · 0.85
cdb2_errstrFunction · 0.85
localtimeFunction · 0.85
cdb2_closeFunction · 0.85
runsqlFunction · 0.70

Tested by

no test coverage detected