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

Function dbstmt_exec

lua/sp.c:3409–3436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3407}
3408
3409static int dbstmt_exec(Lua lua)
3410{
3411 SP sp = getsp(lua);
3412 sqlite3 *sqldb = getdb(sp);
3413
3414 luaL_checkudata(lua, 1, dbtypes.dbstmt);
3415 dbstmt_t *dbstmt = lua_touserdata(lua, 1);
3416 no_stmt_chk(lua, dbstmt);
3417 setup_first_sqlite_step(sp, dbstmt, 0);
3418 sqlite3_stmt *stmt = dbstmt->stmt;
3419 int rc;
3420 lua_begin_step(sp->clnt, sp, stmt);
3421 while ((rc = sqlite3_maybe_step(sp->clnt, stmt)) == SQLITE_ROW) {
3422 lua_another_step(sp->clnt, stmt, rc);
3423 }
3424 lua_end_step(sp->clnt, sp, stmt);
3425 dbstmt->rows_changed = sqlite3_changes(sqldb);
3426 if (rc == SQLITE_DONE) {
3427 sqlite3_reset(stmt);
3428 db_reset(lua);
3429 lua_pushinteger(lua, 0);
3430 return 1;
3431 }
3432 const char *errstr = NULL;
3433 sql_check_errors(sp->clnt, sqldb, stmt, &errstr);
3434 donate_stmt(getsp(lua), dbstmt);
3435 return luabb_error(lua, sp, errstr);
3436}
3437
3438static int dbstmt_fetch(Lua lua)
3439{

Callers

nothing calls this directly

Calls 15

luaL_checkudataFunction · 0.85
lua_touserdataFunction · 0.85
no_stmt_chkFunction · 0.85
setup_first_sqlite_stepFunction · 0.85
lua_begin_stepFunction · 0.85
sqlite3_maybe_stepFunction · 0.85
lua_another_stepFunction · 0.85
lua_end_stepFunction · 0.85
sqlite3_changesFunction · 0.85
sqlite3_resetFunction · 0.85
db_resetFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected