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

Function lua_final

lua/sp.c:7218–7247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7216}
7217
7218void lua_final(sqlite3_context *context)
7219{
7220 lua_func_arg_t *arg = sqlite3_user_data(context);
7221 struct sqlthdstate *thd = arg->thd;
7222 char *spname = arg->name;
7223 struct sqlclntstate *clnt = thd->sqlthd->clnt;
7224 char *err = NULL;
7225 struct sp_state *state = sqlite3_aggregate_context(context, sizeof(*state));
7226 if (state->sp == NULL) {
7227 // step never got called - no matching rows
7228 sqlite3_result_null(context);
7229 return;
7230 }
7231 if (state->sp != clnt->sp) {
7232 swap_sp(&clnt->sp, &state->sp);
7233 }
7234 int rc = lua_final_int(spname, &err, thd, clnt, context);
7235 if (rc != 0) {
7236 sqlite3_result_error(context, err, -1);
7237 } else {
7238 emit_sqlite_result(clnt, context);
7239 }
7240 free(err);
7241 if (state->sp == clnt->sp) {
7242 reset_sp(clnt->sp);
7243 } else {
7244 close_sp(clnt);
7245 restore_sp(clnt, state);
7246 }
7247}
7248
7249void lua_step(sqlite3_context *context, int argc, sqlite3_value **argv)
7250{

Callers

nothing calls this directly

Calls 11

sqlite3_user_dataFunction · 0.85
sqlite3_result_nullFunction · 0.85
swap_spFunction · 0.85
lua_final_intFunction · 0.85
sqlite3_result_errorFunction · 0.85
emit_sqlite_resultFunction · 0.85
freeFunction · 0.85
reset_spFunction · 0.85
close_spFunction · 0.85
restore_spFunction · 0.85

Tested by

no test coverage detected