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

Function db_prepare

lua/sp.c:3784–3806  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3782}
3783
3784static int db_prepare(Lua L)
3785{
3786 SP sp = getsp(L);
3787 luaL_checkudata(L, 1, dbtypes.db);
3788 const char *sql = luabb_tostring(L, 2);
3789 lua_settop(L, 0);
3790 if (sql == NULL) {
3791 luabb_error(L, sp, "bad argument to 'prepare'");
3792 return 2;
3793 }
3794 sqlite3_stmt *stmt = NULL;
3795 struct sql_state *rec = calloc(1, sizeof(*rec));
3796 if (lua_prepare_sql_int(sp, sql, &stmt, rec, lua_get_prepare_flags()) != 0) {
3797 free(rec);
3798 return 2;
3799 }
3800 dbstmt_t *dbstmt = new_dbstmt(L, sp, stmt);
3801 dbstmt->initial = 1;
3802 dbstmt->rec = rec;
3803 sp->prev_dbstmt = dbstmt;
3804 lua_pushinteger(L, 0);
3805 return 2;
3806}
3807
3808static int db_create_thread(Lua L)
3809{

Callers

nothing calls this directly

Calls 10

luaL_checkudataFunction · 0.85
luabb_tostringFunction · 0.85
lua_settopFunction · 0.85
luabb_errorFunction · 0.85
callocFunction · 0.85
lua_prepare_sql_intFunction · 0.85
lua_get_prepare_flagsFunction · 0.85
freeFunction · 0.85
new_dbstmtFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected