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

Function dbstmt_emit

lua/sp.c:3454–3479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3452}
3453
3454static int dbstmt_emit(Lua L)
3455{
3456 SP sp = getsp(L);
3457 luaL_checkudata(L, 1, dbtypes.dbstmt);
3458 dbstmt_t *dbstmt = lua_touserdata(L, 1);
3459 no_stmt_chk(L, dbstmt);
3460 if (!dbstmt->readonly) {
3461 return luaL_error(L, "statement must be read-only");
3462 }
3463 setup_first_sqlite_step(sp, dbstmt, 0);
3464 sqlite3_stmt *stmt = dbstmt->stmt;
3465 int cols = column_count(NULL, stmt);
3466 int rc;
3467 lua_begin_step(sp->clnt, sp, stmt);
3468 while ((rc = sqlite3_maybe_step(sp->clnt, stmt)) == SQLITE_ROW) {
3469 lua_another_step(sp->clnt, stmt, rc);
3470 if (l_send_back_row(L, stmt, cols) != 0) {
3471 rc = -1;
3472 break;
3473 }
3474 }
3475 lua_end_step(sp->clnt, sp, stmt);
3476 reset_stmt(sp, dbstmt);
3477 if (rc == SQLITE_DONE) rc = 0;
3478 return push_and_return(L, rc);
3479}
3480
3481static int dbstmt_close(Lua L)
3482{

Callers 2

dbtable_emit_intFunction · 0.85
db_emit_intFunction · 0.85

Calls 13

luaL_checkudataFunction · 0.85
lua_touserdataFunction · 0.85
no_stmt_chkFunction · 0.85
luaL_errorFunction · 0.85
setup_first_sqlite_stepFunction · 0.85
column_countFunction · 0.85
lua_begin_stepFunction · 0.85
sqlite3_maybe_stepFunction · 0.85
lua_another_stepFunction · 0.85
l_send_back_rowFunction · 0.85
lua_end_stepFunction · 0.85
reset_stmtFunction · 0.85

Tested by

no test coverage detected