| 3452 | } |
| 3453 | |
| 3454 | static 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 | |
| 3481 | static int dbstmt_close(Lua L) |
| 3482 | { |
no test coverage detected