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

Function exec_trigger

lua/sp.c:7307–7342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7305}
7306
7307void *exec_trigger(char *spname)
7308{
7309 char sql[128];
7310 snprintf(sql, sizeof(sql), "exec procedure %s()", spname);
7311
7312 struct sqlclntstate clnt;
7313 start_internal_sql_clnt(&clnt);
7314 clnt.dbtran.mode = TRANLEVEL_SOSQL;
7315 clnt.sql = sql;
7316 clnt.dbtran.trans_has_sp = 1;
7317
7318 thread_memcreate(128 * 1024);
7319 struct sqlthdstate thd = {0};
7320 sqlengine_thd_start(NULL, &thd, THRTYPE_TRIGGER);
7321 thrman_set_subtype(thd.thr_self, THRSUBTYPE_LUA_SQL);
7322 thd.sqlthd->clnt = &clnt;
7323 clnt.thd = &thd;
7324 setup_clnt_for_sp(&clnt);
7325
7326 get_curtran(thedb->bdb_env, &clnt);
7327
7328 char *err = NULL;
7329 int rc = exec_procedure_int(&thd, &clnt, &err, 1);
7330 ctrace("trigger:%s rc:%d err:%s\n", spname, rc, err);
7331 ctrace("trigger:%s stopped running\n", spname);
7332 free(err);
7333 close_sp(&clnt);
7334
7335 put_curtran(thedb->bdb_env, &clnt);
7336
7337 end_internal_sql_clnt(&clnt);
7338 thd.sqlthd->clnt = NULL;
7339 sqlengine_thd_end(NULL, &thd);
7340 thread_memdestroy();
7341 return NULL;
7342}
7343
7344void exec_thread(struct sqlthdstate *thd, struct sqlclntstate *clnt)
7345{

Callers 1

trigger_start_intFunction · 0.85

Calls 14

start_internal_sql_clntFunction · 0.85
thread_memcreateFunction · 0.85
sqlengine_thd_startFunction · 0.85
thrman_set_subtypeFunction · 0.85
setup_clnt_for_spFunction · 0.85
get_curtranFunction · 0.85
exec_procedure_intFunction · 0.85
ctraceFunction · 0.85
freeFunction · 0.85
close_spFunction · 0.85
put_curtranFunction · 0.85
end_internal_sql_clntFunction · 0.85

Tested by

no test coverage detected