int len = sqlite3_column_count (stmt);
Lisp_Object values = Qnil;
- for (int i = 0; i < len; ++i)
+ for (int i = len - 1; i >= 0; i--)
{
Lisp_Object v = Qnil;
values = Fcons (v, values);
}
- return Fnreverse (values);
+ return values;
}
static Lisp_Object
#endif /* HAVE_SQLITE3_LOAD_EXTENSION */
DEFUN ("sqlite-next", Fsqlite_next, Ssqlite_next, 1, 1, 0,
- doc: /* Return the next result set from SET. */)
+ doc: /* Return the next result set from SET.
+Return nil when the statement has finished executing successfully. */)
(Lisp_Object set)
{
check_sqlite (set, true);
+ if (XSQLITE (set)->eof)
+ return Qnil;
+
int ret = sqlite3_step (XSQLITE (set)->stmt);
if (ret != SQLITE_ROW && ret != SQLITE_OK && ret != SQLITE_DONE)
xsignal1 (Qsqlite_error, build_string (sqlite3_errmsg (XSQLITE (set)->db)));