[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] extension loading in sqlite3 egg

From: Kristian Lein-Mathisen
Subject: [Chicken-users] extension loading in sqlite3 egg
Date: Tue, 24 May 2016 11:25:09 +0200

Hi guys!

I wanted to use Spatialite 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:

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 @@
+    enable-load-extension
 (import scheme chicken foreign)
@@ -1034,4 +1035,7 @@ EOS
+(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. 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,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]