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

Function cdb2_send_query

cdb2api/cdb2api.c:3018–3251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3016}
3017
3018static int cdb2_send_query(cdb2_hndl_tp *hndl, cdb2_hndl_tp *event_hndl,
3019 SBUF2 *sb, const char *dbname, const char *sql,
3020 int n_set_commands, int n_set_commands_sent,
3021 char **set_commands, int n_bindvars,
3022 CDB2SQLQUERY__Bindvalue **bindvars, int ntypes,
3023 int *types, int is_begin, int skip_nrows,
3024 int retries_done, int do_append, int fromline)
3025{
3026 int rc = 0;
3027 void *callbackrc;
3028 CDB2SQLQUERY__IdentityBlob *id_blob = NULL;
3029 int overwrite_rc = 0;
3030 cdb2_event *e = NULL;
3031
3032 while ((e = cdb2_next_callback(event_hndl, CDB2_BEFORE_SEND_QUERY, e)) !=
3033 NULL) {
3034 callbackrc = cdb2_invoke_callback(event_hndl, e, 1, CDB2_SQL, sql);
3035 PROCESS_EVENT_CTRL_BEFORE(event_hndl, e, rc, callbackrc, overwrite_rc);
3036 }
3037
3038 if (overwrite_rc)
3039 goto after_callback;
3040
3041 if (log_calls) {
3042 fprintf(stderr, "td 0x%p %s line %d\n", (void *)pthread_self(),
3043 __func__, __LINE__);
3044 }
3045
3046 int n_features = 0;
3047 int features[10]; // Max 10 client features??
3048 CDB2QUERY query = CDB2__QUERY__INIT;
3049 CDB2SQLQUERY sqlquery = CDB2__SQLQUERY__INIT;
3050 CDB2SQLQUERY__Snapshotinfo snapshotinfo;
3051
3052 // This should be sent once right after we connect, not with every query
3053 CDB2SQLQUERY__Cinfo cinfo = CDB2__SQLQUERY__CINFO__INIT;
3054
3055 if (!hndl || !hndl->sent_client_info) {
3056 cinfo.pid = _PID;
3057 cinfo.th_id = (uint64_t)pthread_self();
3058 cinfo.host_id = cdb2_hostid();
3059 cinfo.argv0 = _ARGV0;
3060 if (hndl && hndl->send_stack)
3061 cinfo.stack = hndl->stack;
3062 sqlquery.client_info = &cinfo;
3063 if (hndl)
3064 hndl->sent_client_info = 1;
3065 }
3066
3067 sqlquery.dbname = (char *)dbname;
3068 sqlquery.sql_query = (char *)cdb2_skipws(sql);
3069#if _LINUX_SOURCE
3070 sqlquery.little_endian = 1;
3071#else
3072 sqlquery.little_endian = 0;
3073#endif
3074
3075 sqlquery.n_bindvars = n_bindvars;

Callers 4

retry_query_listFunction · 0.85
retry_queries_and_skipFunction · 0.85
comdb2db_get_dbhostsFunction · 0.85

Calls 6

cdb2_next_callbackFunction · 0.85
cdb2_invoke_callbackFunction · 0.85
cdb2_hostidFunction · 0.85
mallocFunction · 0.85
freeFunction · 0.85
strdupFunction · 0.50

Tested by

no test coverage detected