diff options
| author | Mattias EngdegÄrd | 2022-11-25 10:42:38 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-11-25 11:03:10 +0100 |
| commit | f35dc7058b22a6c7bca23c6696b815f137427fb0 (patch) | |
| tree | 52f15a59eea3555fbf9dd2cd3ea70fc06a15ca38 /src/sqlite.c | |
| parent | 8910447308fa97eaa224b76629bd37b706f62fe1 (diff) | |
| download | emacs-f35dc7058b22a6c7bca23c6696b815f137427fb0.tar.gz emacs-f35dc7058b22a6c7bca23c6696b815f137427fb0.zip | |
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.
Diffstat (limited to 'src/sqlite.c')
| -rw-r--r-- | src/sqlite.c | 14 |
1 files changed, 14 insertions, 0 deletions
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*)); | |||
| 55 | #if SQLITE_VERSION_NUMBER >= 3007015 | 55 | #if SQLITE_VERSION_NUMBER >= 3007015 |
| 56 | DEF_DLL_FN (SQLITE_API const char*, sqlite3_errstr, (int)); | 56 | DEF_DLL_FN (SQLITE_API const char*, sqlite3_errstr, (int)); |
| 57 | #endif | 57 | #endif |
| 58 | DEF_DLL_FN (SQLITE_API const char*, sqlite3_libversion, (void)); | ||
| 58 | DEF_DLL_FN (SQLITE_API int, sqlite3_step, (sqlite3_stmt*)); | 59 | DEF_DLL_FN (SQLITE_API int, sqlite3_step, (sqlite3_stmt*)); |
| 59 | DEF_DLL_FN (SQLITE_API int, sqlite3_changes, (sqlite3*)); | 60 | DEF_DLL_FN (SQLITE_API int, sqlite3_changes, (sqlite3*)); |
| 60 | DEF_DLL_FN (SQLITE_API int, sqlite3_column_count, (sqlite3_stmt*)); | 61 | DEF_DLL_FN (SQLITE_API int, sqlite3_column_count, (sqlite3_stmt*)); |
| @@ -96,6 +97,7 @@ DEF_DLL_FN (SQLITE_API int, sqlite3_load_extension, | |||
| 96 | # if SQLITE_VERSION_NUMBER >= 3007015 | 97 | # if SQLITE_VERSION_NUMBER >= 3007015 |
| 97 | # undef sqlite3_errstr | 98 | # undef sqlite3_errstr |
| 98 | # endif | 99 | # endif |
| 100 | # undef sqlite3_libversion | ||
| 99 | # undef sqlite3_step | 101 | # undef sqlite3_step |
| 100 | # undef sqlite3_changes | 102 | # undef sqlite3_changes |
| 101 | # undef sqlite3_column_count | 103 | # undef sqlite3_column_count |
| @@ -124,6 +126,7 @@ DEF_DLL_FN (SQLITE_API int, sqlite3_load_extension, | |||
| 124 | # if SQLITE_VERSION_NUMBER >= 3007015 | 126 | # if SQLITE_VERSION_NUMBER >= 3007015 |
| 125 | # define sqlite3_errstr fn_sqlite3_errstr | 127 | # define sqlite3_errstr fn_sqlite3_errstr |
| 126 | # endif | 128 | # endif |
| 129 | # define sqlite3_libversion fn_sqlite3_libversion | ||
| 127 | # define sqlite3_step fn_sqlite3_step | 130 | # define sqlite3_step fn_sqlite3_step |
| 128 | # define sqlite3_changes fn_sqlite3_changes | 131 | # define sqlite3_changes fn_sqlite3_changes |
| 129 | # define sqlite3_column_count fn_sqlite3_column_count | 132 | # define sqlite3_column_count fn_sqlite3_column_count |
| @@ -155,6 +158,7 @@ load_dll_functions (HMODULE library) | |||
| 155 | #if SQLITE_VERSION_NUMBER >= 3007015 | 158 | #if SQLITE_VERSION_NUMBER >= 3007015 |
| 156 | LOAD_DLL_FN (library, sqlite3_errstr); | 159 | LOAD_DLL_FN (library, sqlite3_errstr); |
| 157 | #endif | 160 | #endif |
| 161 | LOAD_DLL_FN (library, sqlite3_libversion); | ||
| 158 | LOAD_DLL_FN (library, sqlite3_step); | 162 | LOAD_DLL_FN (library, sqlite3_step); |
| 159 | LOAD_DLL_FN (library, sqlite3_changes); | 163 | LOAD_DLL_FN (library, sqlite3_changes); |
| 160 | LOAD_DLL_FN (library, sqlite3_column_count); | 164 | LOAD_DLL_FN (library, sqlite3_column_count); |
| @@ -763,6 +767,15 @@ This will free the resources held by SET. */) | |||
| 763 | return Qt; | 767 | return Qt; |
| 764 | } | 768 | } |
| 765 | 769 | ||
| 770 | DEFUN ("sqlite-version", Fsqlite_version, Ssqlite_version, 0, 0, 0, | ||
| 771 | doc: /* SQLite library version string. */) | ||
| 772 | (void) | ||
| 773 | { | ||
| 774 | if (!init_sqlite_functions ()) | ||
| 775 | error ("sqlite support is not available"); | ||
| 776 | return build_string (sqlite3_libversion ()); | ||
| 777 | } | ||
| 778 | |||
| 766 | #endif /* HAVE_SQLITE3 */ | 779 | #endif /* HAVE_SQLITE3 */ |
| 767 | 780 | ||
| 768 | DEFUN ("sqlitep", Fsqlitep, Ssqlitep, 1, 1, 0, | 781 | DEFUN ("sqlitep", Fsqlitep, Ssqlitep, 1, 1, 0, |
| @@ -814,6 +827,7 @@ syms_of_sqlite (void) | |||
| 814 | defsubr (&Ssqlite_columns); | 827 | defsubr (&Ssqlite_columns); |
| 815 | defsubr (&Ssqlite_more_p); | 828 | defsubr (&Ssqlite_more_p); |
| 816 | defsubr (&Ssqlite_finalize); | 829 | defsubr (&Ssqlite_finalize); |
| 830 | defsubr (&Ssqlite_version); | ||
| 817 | DEFSYM (Qset, "set"); | 831 | DEFSYM (Qset, "set"); |
| 818 | DEFSYM (Qfull, "full"); | 832 | DEFSYM (Qfull, "full"); |
| 819 | #endif | 833 | #endif |