Thanks David. That works great for my immediate needs. Per below, shell.c doesn't even bother checking return code of sqlite3_create_function(). What could be simpler?
--from shell.c------------------------------------------------------ static void open_db(ShellState *p, int keepAlive){ if( p->db==0 ){ sqlite3_initialize(); sqlite3_open(p->zDbFilename, &p->db); globalDb = p->db;sqlite3_create_function if( p->db && sqlite3_errcode(p->db)==SQLITE_OK ){ sqlite3_create_function(p->db, "shellstatic", 0, SQLITE_UTF8, 0, shellstaticFunc, 0, 0); } if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){ utf8_printf(stderr,"Error: unable to open database \"%s\": %s\n", p->zDbFilename, sqlite3_errmsg(p->db)); if( keepAlive ) return; exit(1); } #ifndef SQLITE_OMIT_LOAD_EXTENSION sqlite3_enable_load_extension(p->db, 1); #endif sqlite3_create_function(p->db, "readfile", 1, SQLITE_UTF8, 0, readfileFunc, 0, 0); sqlite3_create_function(p->db, "writefile", 2, SQLITE_UTF8, 0, writefileFunc, 0, 0); } } ----------------------------------------------------------------------- On Mon, Jun 12, 2017 at 5:57 PM, David Burgess <dburges...@gmail.com> wrote: > Have a look at the way readfile() and writefile() is implemented in the > sqlite interpreter. > > On Tue, Jun 13, 2017 at 10:38 AM, petern <peter.nichvolo...@gmail.com> > wrote: > > > I have a situation where it would be convenient to locate externally > > loadable SQLite extension code in the same compilation unit as the server > > code. Is there a way for server main() to load those extensions located > > within its own compilation unit? Does the necessity of #including both > > sqlite3.h and sqlite3ext.h with SQLITE_EXTENSION_INIT1 macro rule this > out? > > > > Documentation suggests sqlite3_auto_extension() loads a statically linked > > extension entrypoint but trying this on same compilation unit's > > sqlite3_extension_init() entrypoint results in segfault. > > > > FYI, environment is Linux. > > _______________________________________________ > > sqlite-users mailing list > > sqlite-users@mailinglists.sqlite.org > > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > > > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users