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

Function process_line

tools/cdb2sql/cdb2sql.cpp:1698–1755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1696}
1697
1698static void process_line(char *sql, int ntypes, int *types,
1699 int *start_time, int *run_time)
1700{
1701 char *sqlstr = sql;
1702 int rc;
1703 int len;
1704
1705 verbose_print("processing line sql '%.30s...'\n", sql);
1706 /* Trim whitespace and then ignore comments and empty lines. */
1707 while (isspace(*sqlstr))
1708 sqlstr++;
1709
1710 if (sqlstr[0] == '#' || sqlstr[0] == '\0' ||
1711 (sqlstr[0] == '-' && sqlstr[1] == '-'))
1712 return;
1713
1714 /* Lame hack - strip trailing ; so that we can understand the
1715 * sql generated by our own gensql mode. Note that the sql
1716 * parser in comdb2 is ok with semicolons - it stops after the
1717 * first one it encounters. */
1718 len = strlen(sqlstr);
1719 while (len > 0 && isspace(sqlstr[len - 1]))
1720 len--;
1721 while (len > 0 && sqlstr[len - 1] == ';')
1722 len--;
1723 sqlstr[len] = '\0';
1724
1725 int start_time_ms, run_time_ms;
1726 gbl_in_stmt = 1;
1727 rc = run_statement(sqlstr, ntypes, types, &start_time_ms, &run_time_ms);
1728 gbl_in_stmt = 0;
1729 gbl_sent_cancel_cnonce = 0;
1730
1731 if (rc != 0) {
1732 error++;
1733 } else if ((!scriptmode) && !(printmode & DISP_NONE)) {
1734 printf("[%s] rc %d\n", sqlstr, rc);
1735 if (time_mode) {
1736 printf(" prep time %d ms\n", start_time_ms);
1737 printf(" run time %d ms\n", run_time_ms);
1738 }
1739 }
1740
1741 if (start_time) {
1742 *start_time = start_time_ms;
1743 }
1744 if (run_time) {
1745 *run_time = run_time_ms;
1746 }
1747
1748 if (docost && !rc && report_costs == NULL) {
1749 int saved_printmode = printmode;
1750 printmode = DISP_TABS | DISP_STDERR;
1751 const char *costSql = "SELECT comdb2_prevquerycost() as Cost";
1752 run_statement(costSql, ntypes, types, &start_time_ms, &run_time_ms);
1753 printmode = saved_printmode;
1754 }
1755}

Callers 2

do_repeatFunction · 0.70
mainFunction · 0.70

Calls 1

run_statementFunction · 0.70

Tested by

no test coverage detected