| 3782 | } |
| 3783 | |
| 3784 | static 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 | |
| 3808 | static int db_create_thread(Lua L) |
| 3809 | { |
nothing calls this directly
no test coverage detected