emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 20454128b8b: Minor improvements in sqlite.c


From: Eli Zaretskii
Subject: emacs-29 20454128b8b: Minor improvements in sqlite.c
Date: Thu, 2 Feb 2023 14:46:19 -0500 (EST)

branch: emacs-29
commit 20454128b8be9fb3b525ac43f7e5dfa9cc639db0
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Minor improvements in sqlite.c
    
    * src/sqlite.c (Fsqlite_next): Doc fix.  Return nil if SQLITE_DONE
    was once seen for this statement.  (Bug#61151)
    (row_to_value): Cons the value in reverse, to avoid the Fnreverse
    call.  Patch by Helmut Eller <eller.helmut@gmail.com>.
    (Bug#61165)
---
 src/sqlite.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/sqlite.c b/src/sqlite.c
index c96841e63f9..0361514766a 100644
--- a/src/sqlite.c
+++ b/src/sqlite.c
@@ -399,7 +399,7 @@ row_to_value (sqlite3_stmt *stmt)
   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;
 
@@ -434,7 +434,7 @@ row_to_value (sqlite3_stmt *stmt)
       values = Fcons (v, values);
     }
 
-  return Fnreverse (values);
+  return values;
 }
 
 static Lisp_Object
@@ -718,11 +718,15 @@ Only modules on Emacs' list of allowed modules can be 
loaded.  */)
 #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)));



reply via email to

[Prev in Thread] Current Thread [Next in Thread]