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

Function lua_step

lua/sp.c:7249–7281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7247}
7248
7249void lua_step(sqlite3_context *context, int argc, sqlite3_value **argv)
7250{
7251 lua_func_arg_t *arg = sqlite3_user_data(context);
7252 struct sqlthdstate *thd = arg->thd;
7253 char *spname = arg->name;
7254 struct sqlclntstate *clnt = thd->sqlthd->clnt;
7255 char *err = NULL;
7256 struct sp_state *state = sqlite3_aggregate_context(context, sizeof(*state));
7257 if (state->sp == NULL) {
7258 if (clnt->sp && clnt->sp->lua) {
7259 if (strcmp(clnt->sp->spname, spname) == 0) {
7260 // first call and have cached lua vm.
7261 // reset it by parsing again.
7262 process_src(clnt->sp->lua, clnt->sp->src, &err);
7263 }
7264 }
7265 }
7266 if (state->sp != clnt->sp) {
7267 check_sp(spname, clnt, state);
7268 }
7269 int rc = lua_step_int(spname, &err, thd, clnt, context, argc, argv);
7270 if (rc != 0) {
7271 sqlite3_result_error(context, err, -1);
7272 }
7273 free(err);
7274 if (state->sp != clnt->sp) {
7275 if (state->sp) {
7276 swap_sp(&clnt->sp, &state->sp);
7277 } else {
7278 state->sp = clnt->sp;
7279 }
7280 }
7281}
7282
7283void lua_func(sqlite3_context *context, int argc, sqlite3_value **argv)
7284{

Callers

nothing calls this directly

Calls 8

sqlite3_user_dataFunction · 0.85
process_srcFunction · 0.85
check_spFunction · 0.85
lua_step_intFunction · 0.85
sqlite3_result_errorFunction · 0.85
freeFunction · 0.85
swap_spFunction · 0.85

Tested by

no test coverage detected