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

Function add_sql_hint_table

db/sql_stmt_cache.c:398–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396}
397
398static void add_sql_hint_table(char *sql_hint, char *sql_str, void *dta,
399 int dta_sz)
400{
401 int sql_hint_len = strlen(sql_hint) + 1;
402 int sql_len = strlen(sql_str) + 1;
403 int len = sql_hint_len + sql_len + dta_sz;
404 sql_hint_hash_entry_type *entry = malloc(sizeof(*entry) + len);
405
406 entry->sql_hint = entry->mem;
407 memcpy(entry->sql_hint, sql_hint, sql_hint_len);
408
409 entry->sql_str = entry->sql_hint + sql_hint_len;
410 memcpy(entry->sql_str, sql_str, sql_len);
411
412 entry->dta_sz = dta_sz;
413 entry->dta = entry->sql_hint + sql_hint_len + sql_len;
414 if (dta_sz)
415 memcpy(entry->dta, dta, dta_sz);
416
417 Pthread_mutex_lock(&gbl_sql_lock);
418 if (lrucache_hasentry(sql_hints, &sql_hint) == 0) {
419 lrucache_add(sql_hints, entry);
420 } else {
421 free(entry);
422 logmsg(LOGMSG_ERROR, "Client BUG: Two threads using same SQL tag.\n");
423 }
424 Pthread_mutex_unlock(&gbl_sql_lock);
425}
426
427static void dump_sql_hint_entry(void *item, void *p)
428{

Callers 1

stmt_cache_put_intFunction · 0.85

Calls 5

mallocFunction · 0.85
lrucache_hasentryFunction · 0.85
lrucache_addFunction · 0.85
freeFunction · 0.85
logmsgFunction · 0.50

Tested by

no test coverage detected