#include <sqlite3.h>
+/* Support for loading SQLite extensions requires the ability to
+ enable and disable loading of extensions (by default this is
+ disabled, and we want to keep it that way). The required macro is
+ available since SQLite 3.13. */
+# if defined HAVE_SQLITE3_LOAD_EXTENSION && \
+ defined SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION
+# define HAVE_LOAD_EXTENSION 1
+# else
+# define HAVE_LOAD_EXTENSION 0
+# endif
+
#ifdef WINDOWSNT
# include <windows.h>
DEF_DLL_FN (SQLITE_API int, sqlite3_prepare_v2,
(sqlite3*, const char*, int, sqlite3_stmt**, const char**));
-# ifdef HAVE_SQLITE3_LOAD_EXTENSION
+# if HAVE_LOAD_EXTENSION
DEF_DLL_FN (SQLITE_API int, sqlite3_load_extension,
(sqlite3*, const char*, const char*, char**));
# undef sqlite3_load_extension
LOAD_DLL_FN (library, sqlite3_column_text);
LOAD_DLL_FN (library, sqlite3_column_name);
LOAD_DLL_FN (library, sqlite3_exec);
-# ifdef HAVE_SQLITE3_LOAD_EXTENSION
+# if HAVE_LOAD_EXTENSION
LOAD_DLL_FN (library, sqlite3_load_extension);
LOAD_DLL_FN (library, sqlite3_db_config);
# endif
SSDATA (concat2 (build_string ("PRAGMA "), pragma)));
}
-#ifdef HAVE_SQLITE3_LOAD_EXTENSION
+#if HAVE_LOAD_EXTENSION
DEFUN ("sqlite-load-extension", Fsqlite_load_extension,
Ssqlite_load_extension, 2, 2, 0,
doc: /* Load an SQlite MODULE into DB.
}
return Qnil;
}
-#endif /* HAVE_SQLITE3_LOAD_EXTENSION */
+#endif /* HAVE_LOAD_EXTENSION */
DEFUN ("sqlite-next", Fsqlite_next, Ssqlite_next, 1, 1, 0,
doc: /* Return the next result set from SET.
defsubr (&Ssqlite_commit);
defsubr (&Ssqlite_rollback);
defsubr (&Ssqlite_pragma);
-#ifdef HAVE_SQLITE3_LOAD_EXTENSION
+#if HAVE_LOAD_EXTENSION
defsubr (&Ssqlite_load_extension);
#endif
defsubr (&Ssqlite_next);