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

Function verify_dispatch_sql_query

db/sqlinterfaces.c:5106–5139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5104}
5105
5106static int verify_dispatch_sql_query(struct sqlclntstate *clnt)
5107{
5108 memset(clnt->work.zRuleRes, 0, sizeof(clnt->work.zRuleRes));
5109
5110 if (clnt->admin || !gbl_prioritize_queries || !gbl_ruleset) {
5111 return 0;
5112 }
5113
5114 if (gbl_fingerprint_queries &&
5115 comdb2_ruleset_fingerprints_allowed()) {
5116 /* IGNORED */
5117 preview_and_calc_fingerprint(clnt);
5118 }
5119
5120 int ruleNo = 0;
5121 int bRejected = 0;
5122 int bTryAgain = 0;
5123
5124 int ret = can_execute_sql_query_now(clnt->thd, clnt, &ruleNo, &bRejected, &bTryAgain);
5125 if (ret || !bRejected) {
5126 return 0;
5127 }
5128
5129 int rc = bTryAgain ? CDB2ERR_REJECTED: ERR_QUERY_REJECTED;
5130 char zRuleRes[100];
5131 memset(zRuleRes, 0, sizeof(zRuleRes));
5132 snprintf0(zRuleRes, sizeof(zRuleRes), "Rejected due to rule #%d", ruleNo);
5133 if (gbl_verbose_prioritize_queries) {
5134 logmsg(LOGMSG_ERROR, "%s: REJECTED rc=%d {%s}: %s\n",
5135 __func__, rc, clnt->sql, zRuleRes);
5136 }
5137 send_run_error(clnt, zRuleRes, rc);
5138 return rc;
5139}
5140
5141static int dispatch_sql_query_int(struct sqlclntstate *clnt)
5142{

Callers 1

dispatch_sql_query_intFunction · 0.85

Calls 6

snprintf0Function · 0.85
send_run_errorFunction · 0.85
logmsgFunction · 0.50

Tested by

no test coverage detected