summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2022-11-25 10:42:38 +0100
committerMattias EngdegÄrd <mattiase@acm.org>2022-11-25 11:03:10 +0100
commitf35dc7058b22a6c7bca23c6696b815f137427fb0 (patch)
tree52f15a59eea3555fbf9dd2cd3ea70fc06a15ca38
parent8910447308fa97eaa224b76629bd37b706f62fe1 (diff)
downloademacs-f35dc7058b22a6c7bca23c6696b815f137427fb0.tar.gz
Add sqlite library version string retrieval function (bug#58766)
* src/sqlite.c (sqlite3_libversion, load_dll_functions): Make sqlite3_libversion available. (Fsqlite_version): New. (syms_of_sqlite): Define sqlite-version. * doc/lispref/text.texi (Database): Document. * test/src/sqlite-tests.el (sqlite-returning): `RETURNING` was added in sqlite 3.35; skip the test for older versions.
-rw-r--r--doc/lispref/text.texi4
-rw-r--r--src/sqlite.c14
-rw-r--r--test/src/sqlite-tests.el1
3 files changed, 19 insertions, 0 deletions
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 793c22949c8..ef938e88ecf 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -5460,6 +5460,10 @@ Extensions are usually shared-library files; on GNU and Unix systems,
they have the @file{.so} file-name extension.
@end defun
+@defun sqlite-version
+Return a string denoting the version of the SQLite library in use.
+@end defun
+
@findex sqlite-mode-open-file
If you wish to list the contents of an SQLite file, you can use the
@code{sqlite-mode-open-file} command. This will pop to a buffer using
diff --git a/src/sqlite.c b/src/sqlite.c
index ac860f55bcd..c2f90d6a871 100644
--- a/src/sqlite.c
+++ b/src/sqlite.c
@@ -55,6 +55,7 @@ DEF_DLL_FN (SQLITE_API const char*, sqlite3_errmsg, (sqlite3*));
#if SQLITE_VERSION_NUMBER >= 3007015
DEF_DLL_FN (SQLITE_API const char*, sqlite3_errstr, (int));
#endif
+DEF_DLL_FN (SQLITE_API const char*, sqlite3_libversion, (void));
DEF_DLL_FN (SQLITE_API int, sqlite3_step, (sqlite3_stmt*));
DEF_DLL_FN (SQLITE_API int, sqlite3_changes, (sqlite3*));
DEF_DLL_FN (SQLITE_API int, sqlite3_column_count, (sqlite3_stmt*));
@@ -96,6 +97,7 @@ DEF_DLL_FN (SQLITE_API int, sqlite3_load_extension,
# if SQLITE_VERSION_NUMBER >= 3007015
# undef sqlite3_errstr
# endif
+# undef sqlite3_libversion
# undef sqlite3_step
# undef sqlite3_changes
# undef sqlite3_column_count
@@ -124,6 +126,7 @@ DEF_DLL_FN (SQLITE_API int, sqlite3_load_extension,
# if SQLITE_VERSION_NUMBER >= 3007015
# define sqlite3_errstr fn_sqlite3_errstr
# endif
+# define sqlite3_libversion fn_sqlite3_libversion
# define sqlite3_step fn_sqlite3_step
# define sqlite3_changes fn_sqlite3_changes
# define sqlite3_column_count fn_sqlite3_column_count
@@ -155,6 +158,7 @@ load_dll_functions (HMODULE library)
#if SQLITE_VERSION_NUMBER >= 3007015
LOAD_DLL_FN (library, sqlite3_errstr);
#endif
+ LOAD_DLL_FN (library, sqlite3_libversion);
LOAD_DLL_FN (library, sqlite3_step);
LOAD_DLL_FN (library, sqlite3_changes);
LOAD_DLL_FN (library, sqlite3_column_count);
@@ -763,6 +767,15 @@ This will free the resources held by SET. */)
return Qt;
}
+DEFUN ("sqlite-version", Fsqlite_version, Ssqlite_version, 0, 0, 0,
+ doc: /* SQLite library version string. */)
+ (void)
+{
+ if (!init_sqlite_functions ())
+ error ("sqlite support is not available");
+ return build_string (sqlite3_libversion ());
+}
+
#endif /* HAVE_SQLITE3 */
DEFUN ("sqlitep", Fsqlitep, Ssqlitep, 1, 1, 0,
@@ -814,6 +827,7 @@ syms_of_sqlite (void)
defsubr (&Ssqlite_columns);
defsubr (&Ssqlite_more_p);
defsubr (&Ssqlite_finalize);
+ defsubr (&Ssqlite_version);
DEFSYM (Qset, "set");
DEFSYM (Qfull, "full");
#endif
diff --git a/test/src/sqlite-tests.el b/test/src/sqlite-tests.el
index be4f60ab57f..e9ddf9c0bef 100644
--- a/test/src/sqlite-tests.el
+++ b/test/src/sqlite-tests.el
@@ -243,6 +243,7 @@
(ert-deftest sqlite-returning ()
(skip-unless (sqlite-available-p))
+ (skip-unless (version<= "3.35" (sqlite-version)))
(let (db)
(progn
(setq db (sqlite-open))