On Thursday, 5 March, 2020 20:39, Charles Leifer <colei...@gmail.com> wrote:
>Keith, if you could share a bit more details on how you do that, I'd be >interested. I presume you mean how to create a "built-in" extension, which is available for all connections, just the built-in functions and modules. There is a built-in define SQLITE_EXTRA_INIT used in main.c which allows for a "user function" to be called at the end of the SQLite3 initialization process. You compile the code/amalgamation with SQLITE_EXTRA_INIT defined to the name of a function that takes a NULL parameter and returns an SQLITE error code (SQLITE_OK, SQLITE_ERROR, etc). This function is called *after* the SQLite3 core is initialized. It does additional initialization of the library. For example, to autoload some extensions on every connection you can append the code for the extension to the amalgamation sqlite3.c file and then append you EXTRA_INIT function to add the extension init procedure to the auto extension list: -DSQLITE_EXTRA_INIT=coreinit static int coreinit(const char* dummy) ( return sqlite3_auto_extension((void*)sqlite3_series_init); } If you append series.c to the amalgamation, and then the coreinit function, and compile with -DSQLITE_EXTRA_INIT=coreinit, then when SQLite3 is initialized the coreinit function will run after the initialization is complete and add the sqlite3_series_init function to the auto_extension list. Then when any new connection is opened the generate_series extension will be registered on that connection. Of course, the extensions and the coreinit function do not have to be part of the amalgamation compilation unit -- they can be in a separate file and statically linked. -- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users