Subject: | enable_load_extension function |
This is a simple patch to enable "sqlite3_enable_load_extension" as
you can use this function like as following
$dbh->func( 1, "enable_load_extension" );
$sth = $dbh->prepare("select load_extension('libsqlitefunctions.so')")
or die "Cannot prepare: " . $dbh->errstr();
Subject: | perl-DBD-load_extension.diff |
diff -ru DBD-SQLite-1.14/dbdimp.c DBD-SQLite-1.14.my/dbdimp.c
--- DBD-SQLite-1.14/dbdimp.c 2007-08-24 11:51:25.000000000 +0900
+++ DBD-SQLite-1.14.my/dbdimp.c 2008-02-08 03:48:30.415496532 +0900
@@ -876,6 +876,21 @@
}
}
+void
+sqlite3_db_enable_load_extension( SV *dbh, int onoff )
+{
+ D_imp_dbh(dbh);
+ int rv;
+
+ /* warn("create_function %s with %d args\n", name, argc); */
+ rv = sqlite3_enable_load_extension( imp_dbh->db, onoff );
+ if ( rv != SQLITE_OK )
+ {
+ croak( "sqlite_enable_load_extension failed with error %s",
+ sqlite3_errmsg(imp_dbh->db) );
+ }
+}
+
typedef struct aggrInfo aggrInfo;
struct aggrInfo {
SV *aggr_inst;
diff -ru DBD-SQLite-1.14/dbdimp.h DBD-SQLite-1.14.my/dbdimp.h
--- DBD-SQLite-1.14/dbdimp.h 2007-08-23 09:45:08.000000000 +0900
+++ DBD-SQLite-1.14.my/dbdimp.h 2008-02-08 03:47:20.997862251 +0900
@@ -75,6 +75,7 @@
#define dbd_st_bind_col sqlite_bind_col
void sqlite_db_create_function(SV *dbh, const char *name, int argc, SV *func);
+void sqlite_db_enable_load_extension(SV *dbh, int onoff);
void sqlite_db_create_aggregate( SV *dbh, const char *name, int argc, SV *aggr );
#ifdef SvUTF8_on
diff -ru DBD-SQLite-1.14/SQLite.xs DBD-SQLite-1.14.my/SQLite.xs
--- DBD-SQLite-1.14/SQLite.xs 2007-08-23 09:01:07.000000000 +0900
+++ DBD-SQLite-1.14.my/SQLite.xs 2008-02-08 03:47:07.757035088 +0900
@@ -44,6 +44,15 @@
}
void
+enable_load_extension(dbh, onoff)
+ SV *dbh
+ int onoff
+ CODE:
+ {
+ sqlite3_db_enable_load_extension( dbh, onoff );
+ }
+
+void
create_aggregate(dbh, name, argc, aggr)
SV *dbh
char *name