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

Function run_func

lua/sp.c:7020–7037  ·  view source on GitHub ↗

This runs some Lua code in context of on-going SQL stmt. Should not * start/commit/rollback ongoing transaction. Calling SQL stmt will cleanup on * error. */

Source from the content-addressed store, hash-verified

7018 * start/commit/rollback ongoing transaction. Calling SQL stmt will cleanup on
7019 * error. */
7020static int run_func(struct sqlclntstate *clnt, int argcnt, char **err, int final)
7021{
7022 Lua L = clnt->sp->lua;
7023 int rc = lua_pcall(L, argcnt, LUA_MULTRET, 0);
7024 join_threads(clnt->sp);
7025 if (final || rc) {
7026 reset_stmts(clnt->sp);
7027 drop_temp_tables(clnt->sp);
7028 }
7029 if (rc) {
7030 if (lua_gettop(L) > 0 && !lua_isnil(L, -1)) {
7031 *err = strdup(luabb_tostring(L, -1));
7032 } else {
7033 *err = strdup("UDF failed");
7034 }
7035 }
7036 return rc;
7037}
7038
7039/* TODO: This needs to be more robust - perhaps a hash table of Lua VMs per UDF
7040 * allowing us to invoke multiple UDFs per SQL statement. Also, test running

Callers 3

lua_final_intFunction · 0.85
lua_step_intFunction · 0.85
lua_func_intFunction · 0.85

Calls 7

lua_pcallFunction · 0.85
join_threadsFunction · 0.85
reset_stmtsFunction · 0.85
drop_temp_tablesFunction · 0.85
lua_gettopFunction · 0.85
luabb_tostringFunction · 0.85
strdupFunction · 0.50

Tested by

no test coverage detected