diff options
Diffstat (limited to 'src/sqlite.c')
| -rw-r--r-- | src/sqlite.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/sqlite.c b/src/sqlite.c index 08bf696b8ca..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)); | |||
| 52 | DEF_DLL_FN (SQLITE_API int, sqlite3_bind_int, (sqlite3_stmt*, int, int)); | 52 | DEF_DLL_FN (SQLITE_API int, sqlite3_bind_int, (sqlite3_stmt*, int, int)); |
| 53 | DEF_DLL_FN (SQLITE_API int, sqlite3_extended_errcode, (sqlite3*)); | 53 | DEF_DLL_FN (SQLITE_API int, sqlite3_extended_errcode, (sqlite3*)); |
| 54 | DEF_DLL_FN (SQLITE_API const char*, sqlite3_errmsg, (sqlite3*)); | 54 | DEF_DLL_FN (SQLITE_API const char*, sqlite3_errmsg, (sqlite3*)); |
| 55 | #if SQLITE_VERSION_NUMBER >= 3007015 | ||
| 55 | DEF_DLL_FN (SQLITE_API const char*, sqlite3_errstr, (int)); | 56 | DEF_DLL_FN (SQLITE_API const char*, sqlite3_errstr, (int)); |
| 57 | #endif | ||
| 56 | DEF_DLL_FN (SQLITE_API int, sqlite3_step, (sqlite3_stmt*)); | 58 | DEF_DLL_FN (SQLITE_API int, sqlite3_step, (sqlite3_stmt*)); |
| 57 | DEF_DLL_FN (SQLITE_API int, sqlite3_changes, (sqlite3*)); | 59 | DEF_DLL_FN (SQLITE_API int, sqlite3_changes, (sqlite3*)); |
| 58 | DEF_DLL_FN (SQLITE_API int, sqlite3_column_count, (sqlite3_stmt*)); | 60 | DEF_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,13 +436,27 @@ row_to_value (sqlite3_stmt *stmt) | |||
| 428 | static Lisp_Object | 436 | static Lisp_Object |
| 429 | sqlite_prepare_errdata (int code, sqlite3 *sdb) | 437 | sqlite_prepare_errdata (int code, sqlite3 *sdb) |
| 430 | { | 438 | { |
| 431 | Lisp_Object errstr = build_string (sqlite3_errstr (code)); | ||
| 432 | Lisp_Object errcode = make_fixnum (code); | 439 | Lisp_Object errcode = make_fixnum (code); |
| 433 | /* More details about what went wrong. */ | ||
| 434 | Lisp_Object ext_errcode = make_fixnum (sqlite3_extended_errcode (sdb)); | ||
| 435 | const char *errmsg = sqlite3_errmsg (sdb); | 440 | const char *errmsg = sqlite3_errmsg (sdb); |
| 436 | return list4 (errstr, errmsg ? build_string (errmsg) : Qnil, | 441 | Lisp_Object lerrmsg = errmsg ? build_string (errmsg) : Qnil; |
| 437 | errcode, ext_errcode); | 442 | Lisp_Object errstr, ext_errcode; |
| 443 | |||
| 444 | #if SQLITE_VERSION_NUMBER >= 3007015 | ||
| 445 | errstr = build_string (sqlite3_errstr (code)); | ||
| 446 | #else | ||
| 447 | /* The internet says this is identical to sqlite3_errstr (code). */ | ||
| 448 | errstr = lerrmsg; | ||
| 449 | #endif | ||
| 450 | |||
| 451 | /* More details about what went wrong. */ | ||
| 452 | #if SQLITE_VERSION_NUMBER >= 3006005 | ||
| 453 | ext_errcode = make_fixnum (sqlite3_extended_errcode (sdb)); | ||
| 454 | #else | ||
| 455 | /* What value to use here? */ | ||
| 456 | ext_errcode = make_fixnum (0); | ||
| 457 | #endif | ||
| 458 | |||
| 459 | return list4 (errstr, lerrmsg, errcode, ext_errcode); | ||
| 438 | } | 460 | } |
| 439 | 461 | ||
| 440 | DEFUN ("sqlite-execute", Fsqlite_execute, Ssqlite_execute, 2, 3, 0, | 462 | DEFUN ("sqlite-execute", Fsqlite_execute, Ssqlite_execute, 2, 3, 0, |