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

Function indexes_expressions_data

db/sqlglue.c:12648–12722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12646}
12647
12648int indexes_expressions_data(const struct dbtable *tbl, struct schema *sc,
12649 const char *inbuf, char *outbuf, blob_buffer_t *blobs,
12650 size_t maxblobs, struct field *f,
12651 struct convert_failure *fail_reason,
12652 const char *tzname)
12653{
12654 Mem *m = NULL;
12655 Mem mout = {{0}};
12656 int nblobs = 0;
12657 struct field_conv_opts_tz convopts = {.flags = 0};
12658 struct mem_info info;
12659 strbuf *sql;
12660 int i, rc;
12661 int exist = 0;
12662
12663 if (!inbuf || !outbuf) {
12664 logmsg(LOGMSG_ERROR, "%s: invalid input\n", __func__);
12665 return -1;
12666 }
12667
12668 if (!tzname || !tzname[0])
12669 tzname = "America/New_York";
12670
12671 sql = strbuf_new();
12672
12673 m = (Mem *)alloca(sizeof(Mem) * sc->nmembers);
12674
12675 for (i = 0; i < sc->nmembers; i++) {
12676 memset(&m[i], 0, sizeof(Mem));
12677 rc = get_data_from_ondisk(tbl, sc, (uint8_t *)inbuf, blobs, maxblobs, i,
12678 &m[i], 0, tzname);
12679 if (rc) {
12680 logmsg(LOGMSG_ERROR, "%s: failed to convert to ondisk\n", __func__);
12681 goto done;
12682 }
12683 }
12684
12685 build_indexes_expressions_query(sql, sc, "expridx_temp", f->name);
12686
12687 rc =
12688 run_verify_indexes_query((char *)strbuf_buf(sql), sc, m, &mout, &exist);
12689 if (rc || !exist) {
12690 logmsg(LOGMSG_ERROR, "%s: failed to run internal query, rc %d\n",
12691 __func__, rc);
12692 rc = -1;
12693 goto done;
12694 }
12695
12696 info.s = sc;
12697 info.null = 0;
12698 info.fail_reason = fail_reason;
12699 info.tzname = tzname;
12700 info.m = &mout;
12701 info.nblobs = &nblobs;
12702 info.convopts = &convopts;
12703 info.outblob = NULL;
12704 info.maxblobs = maxblobs;
12705 info.fldidx = -1;

Callers 1

stag_to_stag_fieldFunction · 0.85

Calls 9

get_data_from_ondiskFunction · 0.85
run_verify_indexes_queryFunction · 0.85
mem_to_ondiskFunction · 0.85
freeFunction · 0.85
logmsgFunction · 0.50
strbuf_newFunction · 0.50
strbuf_bufFunction · 0.50
strbuf_freeFunction · 0.50

Tested by

no test coverage detected