aboutsummaryrefslogtreecommitdiffstats
path: root/src/sqlite.c
diff options
context:
space:
mode:
authorEli Zaretskii2022-11-05 14:28:53 +0200
committerEli Zaretskii2022-11-05 14:28:53 +0200
commitae497d75f74f7ef0830f6cb760fa786a589e290d (patch)
tree7135d97224fc64ccbb787308f884670658fa7d30 /src/sqlite.c
parente275dd289437547414b22cda3227305fb6a85854 (diff)
downloademacs-ae497d75f74f7ef0830f6cb760fa786a589e290d.tar.gz
emacs-ae497d75f74f7ef0830f6cb760fa786a589e290d.zip
Fix warnings in sqlite.c in the MS-Windows build
* src/sqlite.c (sqlite3_errstr) [WINDOWSNT]: Define and load from the DLL only if the SQLite3 version is at least 3.7.15. (sqlite_prepare_errdata) [SQLITE_VERSION_NUMBER >= 3007015]: Use the original code if sqlite3_errstr is available.
Diffstat (limited to 'src/sqlite.c')
-rw-r--r--src/sqlite.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/sqlite.c b/src/sqlite.c
index 906d0640003..ac860f55bcd 100644
--- a/src/sqlite.c
+++ b/src/sqlite.c
@@ -52,7 +52,9 @@ DEF_DLL_FN (SQLITE_API int, sqlite3_bind_null, (sqlite3_stmt*, int));
52DEF_DLL_FN (SQLITE_API int, sqlite3_bind_int, (sqlite3_stmt*, int, int)); 52DEF_DLL_FN (SQLITE_API int, sqlite3_bind_int, (sqlite3_stmt*, int, int));
53DEF_DLL_FN (SQLITE_API int, sqlite3_extended_errcode, (sqlite3*)); 53DEF_DLL_FN (SQLITE_API int, sqlite3_extended_errcode, (sqlite3*));
54DEF_DLL_FN (SQLITE_API const char*, sqlite3_errmsg, (sqlite3*)); 54DEF_DLL_FN (SQLITE_API const char*, sqlite3_errmsg, (sqlite3*));
55#if SQLITE_VERSION_NUMBER >= 3007015
55DEF_DLL_FN (SQLITE_API const char*, sqlite3_errstr, (int)); 56DEF_DLL_FN (SQLITE_API const char*, sqlite3_errstr, (int));
57#endif
56DEF_DLL_FN (SQLITE_API int, sqlite3_step, (sqlite3_stmt*)); 58DEF_DLL_FN (SQLITE_API int, sqlite3_step, (sqlite3_stmt*));
57DEF_DLL_FN (SQLITE_API int, sqlite3_changes, (sqlite3*)); 59DEF_DLL_FN (SQLITE_API int, sqlite3_changes, (sqlite3*));
58DEF_DLL_FN (SQLITE_API int, sqlite3_column_count, (sqlite3_stmt*)); 60DEF_DLL_FN (SQLITE_API int, sqlite3_column_count, (sqlite3_stmt*));
@@ -91,7 +93,9 @@ DEF_DLL_FN (SQLITE_API int, sqlite3_load_extension,
91# undef sqlite3_bind_int 93# undef sqlite3_bind_int
92# undef sqlite3_extended_errcode 94# undef sqlite3_extended_errcode
93# undef sqlite3_errmsg 95# undef sqlite3_errmsg
94# undef sqlite3_errstr 96# if SQLITE_VERSION_NUMBER >= 3007015
97# undef sqlite3_errstr
98# endif
95# undef sqlite3_step 99# undef sqlite3_step
96# undef sqlite3_changes 100# undef sqlite3_changes
97# undef sqlite3_column_count 101# undef sqlite3_column_count
@@ -117,7 +121,9 @@ DEF_DLL_FN (SQLITE_API int, sqlite3_load_extension,
117# define sqlite3_bind_int fn_sqlite3_bind_int 121# define sqlite3_bind_int fn_sqlite3_bind_int
118# define sqlite3_extended_errcode fn_sqlite3_extended_errcode 122# define sqlite3_extended_errcode fn_sqlite3_extended_errcode
119# define sqlite3_errmsg fn_sqlite3_errmsg 123# define sqlite3_errmsg fn_sqlite3_errmsg
120# define sqlite3_errstr fn_sqlite3_errstr 124# if SQLITE_VERSION_NUMBER >= 3007015
125# define sqlite3_errstr fn_sqlite3_errstr
126# endif
121# define sqlite3_step fn_sqlite3_step 127# define sqlite3_step fn_sqlite3_step
122# define sqlite3_changes fn_sqlite3_changes 128# define sqlite3_changes fn_sqlite3_changes
123# define sqlite3_column_count fn_sqlite3_column_count 129# define sqlite3_column_count fn_sqlite3_column_count
@@ -146,7 +152,9 @@ load_dll_functions (HMODULE library)
146 LOAD_DLL_FN (library, sqlite3_bind_int); 152 LOAD_DLL_FN (library, sqlite3_bind_int);
147 LOAD_DLL_FN (library, sqlite3_extended_errcode); 153 LOAD_DLL_FN (library, sqlite3_extended_errcode);
148 LOAD_DLL_FN (library, sqlite3_errmsg); 154 LOAD_DLL_FN (library, sqlite3_errmsg);
155#if SQLITE_VERSION_NUMBER >= 3007015
149 LOAD_DLL_FN (library, sqlite3_errstr); 156 LOAD_DLL_FN (library, sqlite3_errstr);
157#endif
150 LOAD_DLL_FN (library, sqlite3_step); 158 LOAD_DLL_FN (library, sqlite3_step);
151 LOAD_DLL_FN (library, sqlite3_changes); 159 LOAD_DLL_FN (library, sqlite3_changes);
152 LOAD_DLL_FN (library, sqlite3_column_count); 160 LOAD_DLL_FN (library, sqlite3_column_count);
@@ -428,14 +436,17 @@ row_to_value (sqlite3_stmt *stmt)
428static Lisp_Object 436static Lisp_Object
429sqlite_prepare_errdata (int code, sqlite3 *sdb) 437sqlite_prepare_errdata (int code, sqlite3 *sdb)
430{ 438{
431 Lisp_Object errstr, errcode, ext_errcode; 439 Lisp_Object errcode = make_fixnum (code);
432 const char *errmsg; 440 const char *errmsg = sqlite3_errmsg (sdb);
441 Lisp_Object lerrmsg = errmsg ? build_string (errmsg) : Qnil;
442 Lisp_Object errstr, ext_errcode;
433 443
434 /* The internet says this is identical to sqlite3_errstr (code), 444#if SQLITE_VERSION_NUMBER >= 3007015
435 which is too new to exist on Fedora 9. */ 445 errstr = build_string (sqlite3_errstr (code));
436 errmsg = sqlite3_errmsg (sdb); 446#else
437 errstr = errmsg ? build_string (errmsg) : Qnil; 447 /* The internet says this is identical to sqlite3_errstr (code). */
438 errcode = make_fixnum (code); 448 errstr = lerrmsg;
449#endif
439 450
440 /* More details about what went wrong. */ 451 /* More details about what went wrong. */
441#if SQLITE_VERSION_NUMBER >= 3006005 452#if SQLITE_VERSION_NUMBER >= 3006005
@@ -445,8 +456,7 @@ sqlite_prepare_errdata (int code, sqlite3 *sdb)
445 ext_errcode = make_fixnum (0); 456 ext_errcode = make_fixnum (0);
446#endif 457#endif
447 458
448 return list4 (errstr, errmsg ? build_string (errmsg) : Qnil, 459 return list4 (errstr, lerrmsg, errcode, ext_errcode);
449 errcode, ext_errcode);
450} 460}
451 461
452DEFUN ("sqlite-execute", Fsqlite_execute, Ssqlite_execute, 2, 3, 0, 462DEFUN ("sqlite-execute", Fsqlite_execute, Ssqlite_execute, 2, 3, 0,