2014-07-22 0:13 GMT+02:00 Peter Aronson <pbaron...@att.net>:
> Found in 3.8.4.3.  Missing from sqlite3ext.h are sqlite3_auto_extension() and 
> sqlite3_cancel_auto_extension().
>
> Now, you might ask, why would I need these functions in an extension?  Well, 
> it turns out I'm writing a virtual table that accesses someone else's library 
> that also uses SQLite, at least some of the time, and I don't want my 
> extension being run on that library's SQLite connection.  At best it's a 
> waste of time, and at worst it could confuse the other library.  So I call 
> sqlite3_cancel_auto_extension() to cancel my extension before calling the 
> other library's open function (which might open SQLite), and afterwards I set 
> it again using sqlite3_auto_extension().

Sounds reasonable to me. Suggested patch below.

Regards,
         Jan Nijtmans

Index: src/loadext.c
==================================================================
--- src/loadext.c
+++ src/loadext.c
@@ -388,11 +388,16 @@
   sqlite3_stricmp,
   sqlite3_uri_boolean,
   sqlite3_uri_int64,
   sqlite3_uri_parameter,
   sqlite3_vsnprintf,
-  sqlite3_wal_checkpoint_v2
+  sqlite3_wal_checkpoint_v2,
+  /*
+  ** Added for 3.8.6
+  */
+  sqlite3_auto_extension,
+  sqlite3_cancel_auto_extension
 };

 /*
 ** Attempt to load an SQLite extension library contained in the file
 ** zFile.  The entry point is zProc.  zProc may be 0 in which case a

Index: src/sqlite3ext.h
==================================================================
--- src/sqlite3ext.h
+++ src/sqlite3ext.h
@@ -248,10 +248,13 @@
   int (*uri_boolean)(const char*,const char*,int);
   sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
   const char *(*uri_parameter)(const char*,const char*);
   char *(*vsnprintf)(int,char*,const char*,va_list);
   int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
+  /* Version 3.8.6 and later */
+  int (*auto_extension)(void (*xInit)(void));
+  int (*cancel_auto_extension)(void (*xInit)(void));
 };

 /*
 ** The following macros redefine the API routines so that they are
 ** redirected throught the global sqlite3_api structure.
@@ -465,10 +468,12 @@
 #define sqlite3_uri_boolean            sqlite3_api->uri_boolean
 #define sqlite3_uri_int64              sqlite3_api->uri_int64
 #define sqlite3_uri_parameter          sqlite3_api->uri_parameter
 #define sqlite3_uri_vsnprintf          sqlite3_api->vsnprintf
 #define sqlite3_wal_checkpoint_v2      sqlite3_api->wal_checkpoint_v2
+#define sqlite3_auto_extension         sqlite3_api->auto_extension
+#define sqlite3_cancel_auto_extension  sqlite3_api->cancel_auto_extension
 #endif /* SQLITE_CORE */

 #ifndef SQLITE_CORE
   /* This case when the file really is being compiled as a loadable
   ** extension */
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to