Hi guys!

I wanted to use Spatialite
<https://www.gaia-gis.it/fossil/libspatialite/index> with CHICKEN and
though I'd use the sqlite3 egg. However, I quickly ran into a problem:

(execute db "select load_extension(\"mod_spatialite\");")
Error: (finalize!) not authorized: #<sqlite3:statement sql="">

Call history:

ff-testing.scm:1: ##sys#require
type-checks.scm:54: ##sys#require
sql-null.scm:14: constantly
ff-testing.scm:3: sqlite3#open-database
ff-testing.scm:7: sqlite3#first-row
ff-testing.scm:7: print
ff-testing.scm:9: sqlite3#execute   <--

In the sqlite3 command-line, this works fine. The solution was to enable
extension loading which is not allowed by default:
https://www.sqlite.org/c3ref/enable_load_extension.html

However, this Sqlite3 function isn't available in the egg. Here's a rather
trivial patch that adds it:

diff --git a/sqlite3.scm b/sqlite3.scm
index dd7f35f..ce039da 100644
--- a/sqlite3.scm
+++ b/sqlite3.scm
@@ -69,6 +69,7 @@
     database-memory-used
     database-memory-highwater
     enable-shared-cache!
+    enable-load-extension
   )

 (import scheme chicken foreign)
@@ -1034,4 +1035,7 @@ EOS
      [else
       enable?])]))

+(define (enable-load-extension db enable?)
+  ((foreign-lambda sqlite3:status "sqlite3_enable_load_extension"
sqlite3:database bool) db enable?))
+
 )

Which now makes

(enable-load-extension db #t)
(execute db "select load_extension(\"mod_spatialite\");")

Work like a charm.

I'm not sure how to get this patch upstream
<http://bugs.call-cc.org/browser/project/release/4/sqlite3/trunk/sqlite3.scm>.
I
don't think I have SVN access. So I was hoping the current sqlite3
maintainer wouldn't mind fixing this (eyes on you Thomas Chust! :D)!

Thank you,
K.
_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to