Subject: 29.0.91; [PATCH] More fix for loading SQLite extensions

From: lin Sun <[email-masked]>
Date: Tue, 23 May 2023 04:52:45 +0000

Sorry for no PATH file in my previous mail.
Here's the path file.
From 332e9c3c2253b40584ba76de4e3644204acbfcdc Mon Sep 17 00:00:00 2001
From: Lin Sun <[email-masked]>
Date: Tue, 23 May 2023 00:00:12 +0000
Subject: [PATCH] More fix for loading SQLite extensions

* src/sqlite.c (sqlite3_db_config): Load from the dylib.
(Fsqlite_load_extension): rely on the SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION
existence.
---
 src/sqlite.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/sqlite.c b/src/sqlite.c
index 77ce61ba65..363a52b317 100644
--- a/src/sqlite.c
+++ b/src/sqlite.c
@@ -722,6 +722,7 @@ DEFUN ("sqlite-load-extension", Fsqlite_load_extension,
       if (strlen (*allow) < strlen (name)
 	  && !strncmp (*allow, name, strlen (*allow))
 	  && (!strcmp (name + strlen (*allow), ".so")
+	      || !strcmp (name + strlen (*allow), ".dylib")
 	      || !strcasecmp (name + strlen (*allow), ".dll")))
 	{
 	  do_allow = true;
@@ -737,14 +738,18 @@ DEFUN ("sqlite-load-extension", Fsqlite_load_extension,
      "leak" this outside this function.  */
   sqlite3 *sdb = XSQLITE (db)->db;
   char *ext_fn = SSDATA (ENCODE_FILE (Fexpand_file_name (module, Qnil)));
+#ifdef SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION
   /* Temporarily enable loading extensions via the C API.  */
   int result = sqlite3_db_config (sdb, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1,
 				  NULL);
   if (result == SQLITE_OK)
+#endif
     {
-      result = sqlite3_load_extension (sdb, ext_fn, NULL, NULL);
+      int result = sqlite3_load_extension (sdb, ext_fn, NULL, NULL);
       /* Disable loading extensions via C API.  */
+#ifdef SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION
       sqlite3_db_config (sdb, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 0, NULL);
+#endif
       if (result == SQLITE_OK)
 	return Qt;
     }
-- 
2.20.5