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

Function cdb2_bind_param

cdb2api/cdb2api.c:5326–5359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5324}
5325
5326int cdb2_bind_param(cdb2_hndl_tp *hndl, const char *varname, int type,
5327 const void *varaddr, int length)
5328{
5329 hndl->n_bindvars++;
5330 hndl->bindvars = realloc(hndl->bindvars, sizeof(CDB2SQLQUERY__Bindvalue *) *
5331 hndl->n_bindvars);
5332 CDB2SQLQUERY__Bindvalue *bindval = malloc(sizeof(CDB2SQLQUERY__Bindvalue));
5333 cdb2__sqlquery__bindvalue__init(bindval);
5334 bindval->type = type;
5335 bindval->varname = (char *)varname;
5336 bindval->value.data = (void *)varaddr;
5337 bindval->value.len = length;
5338 if (length == 0) {
5339 /* protobuf-c discards `data' if `len' is 0. A NULL value and a 0-length
5340 value would look the same from the server's perspective. Hence we
5341 need an addtional isnull flag to tell them apart. */
5342 bindval->has_isnull = 1;
5343 bindval->isnull = (varaddr == NULL);
5344
5345 /* R6 and old R7 ignore isnull for cstring and treat a 0-length string
5346 as NULL. So we send 1 dummy byte here to be backward compatible with
5347 an old backend. */
5348 if (type == CDB2_CSTRING && !bindval->isnull) {
5349 bindval->value.data = (unsigned char *)"";
5350 bindval->value.len = 1;
5351 }
5352 }
5353 hndl->bindvars[hndl->n_bindvars - 1] = bindval;
5354 if (log_calls)
5355 fprintf(stderr, "%p> cdb2_bind_param(%p, \"%s\", %s, %p, %d) = 0\n",
5356 (void *)pthread_self(), hndl, varname, cdb2_type_str(type),
5357 varaddr, length);
5358 return 0;
5359}
5360
5361int cdb2_bind_index(cdb2_hndl_tp *hndl, int index, int type,
5362 const void *varaddr, int length)

Callers 15

process_bindFunction · 0.85
sav_portMethod · 0.85
del_portMethod · 0.85
get_portsMethod · 0.85
do_bindingsFunction · 0.85
insert_records_thdFunction · 0.85
update_records_thdFunction · 0.85
bind_valueFunction · 0.85
apply_delFunction · 0.85
apply_opFunction · 0.85
apply_seqnoFunction · 0.85
mainFunction · 0.85

Calls 3

reallocFunction · 0.85
mallocFunction · 0.85
cdb2_type_strFunction · 0.70

Tested by 4

mainFunction · 0.68
mainFunction · 0.68
test_bind_paramFunction · 0.68
run_statementFunction · 0.68