On Thursday, 23 May, 2019 02:08, Dominique Devienne <ddevie...@gmail.com> wrote:

>On Thu, May 23, 2019 at 7:39 AM Keith Medcalf <kmedc...@dessus.com>
>wrote:

>> You can check if what you need is available on a connection and
>either load it if needed or just abort:

>> sqlite> select * from pragma_function_list order by 1, 2;
>> name                       builtin
>> -------------------------  ----------
>> aavg                       0
>> ...
>> sqlite> select * from pragma_collation_list order by 1, 2;
>> seq                        name
>> -------------------------  ----------
>> 0                          ROT13
>> ...
>> sqlite> select * from pragma_module_list order by 1;
>> name
>> -------------------------
>> approximate_match
>> carray
>> completion
>> ...
>> sqlite> select * from pragma_compile_options;
>> compile_options
>> ALLOW_COVERING_INDEX_SCAN
>> ...

>Keith, as can be seen below, those pragma_*list eponymous vtables are
>you referring to as not built-in.

Actually they are.  They are the eponymous vtables for the corresponding 
pragma's:

pragma function_list;
pragma collation_list;
pragma module_list;

>I wasn't even aware one could get the function-list at all. Did you
>implement that as a pure extension w/o changing the official SQLite 
>source code? Are all your extensions Open-Source, on GitHub or 
somewhere?

https://sqlite.org/pragma.html#pragma_function_list

The pragma's and the eponymous vtables are built in but only if you compile the 
code with the SQLITE_INTROSPECTION_PRAGMAS defined during the compile (and that 
symbol is not listed as part of the pragma compile_options, unfortunately.  
Perhaps Richard could add than so it would be easier to tell if those were 
available rather than trying to use the pragma or the vtables and getting 
nothing or an error respectively.

You can find the source for all the extensions (and the compiled dll's for 
windows, compiled with MinGW) here (excluding the sqltime.c module which only 
works internally and not as an extension and does require changes to the 
sqlite3.c date.c module, that makes the DateTime output default to having 
miliseconds and a timezone offset, plus the ability to specify IANA timezone 
names as parameters eg datetime('now','america/chicago') -- that requires 
certain tables to be present as well to do the translations):

https://www.dessus.com/files/SQLiteExtensions.zip
https://www.dessus.com/files/SQLiteExtensions64.zip

A bunch of them are copies of the standard SQLite3 ext/misc extensions, some of 
them I wrote, and some of them came from elsewhere and the attributions are in 
the source files and are all freely available (public domain or otherwise).  
Basically I append the whole lot to the end of the sqlite3.c source and then 
add a coreinit.c that uses the builtin SQLITE_EXTRA_INIT=core_init that hooks 
all the init routines to each connection using the sqlite3_auto_extension 
interface when sqlite3 is initialized.

I will eventually get around to publishing copies of them somewhere.

--//-- coreinit.c --//--

#ifdef USE_NUNICODE
extern void* sqlite3_nunicode_init(void*);
#endif

int core_init(const char* dummy)
{
    int nErr = 0;

    nErr += sqlite3_auto_extension((void*)sqlite3_autobusy_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_ipaddress_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_sqlfcmp_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_sqlfunc_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_sqlfwin_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_sqlhash_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_sqlitemprint_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_sqlmath_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_sqltime_init);

#ifdef USE_NUNICODE
    nErr += sqlite3_auto_extension((void*)sqlite3_nunicode_init);
#else
    nErr += sqlite3_auto_extension((void*)sqlite3_unifuzz_init);
#endif

    nErr += sqlite3_auto_extension((void*)sqlite3_eval_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_fileio_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_ieee_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_nextchar_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_percentile_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_regexp_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_rot_init);
//  nErr += sqlite3_auto_extension((void*)sqlite3_sha_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_totype_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_zorder_init);

    nErr += sqlite3_auto_extension((void*)sqlite3_fossildelta_init);

#ifndef SQLITE_OMIT_VIRTUALTABLE
    nErr += sqlite3_auto_extension((void*)sqlite3_amatch_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_btreeinfo_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_carray_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_closure_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_csv_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_fuzzer_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_memstat_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_prefixes_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_series_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_spellfix_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_unionvtab_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_vtshim_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_wholenumber_init);
#ifdef SQLITE_ENABLE_VFSSTAT
    nErr += sqlite3_vfsstat_init((void*)dummy, (void*)0, (void*)0);
#endif
#ifndef _MSC_VER
    nErr += sqlite3_auto_extension((void*)sqlite3_interpolate_init);
#endif
#endif

#ifndef _MSC_VER
    nErr += sqlite3_auto_extension((void*)sqlite3_compress_init);
#endif

    return nErr ? SQLITE_ERROR : SQLITE_OK;
}
--//-- end --//--


>Thanks, --DD
>
>C:\Users\ddevienne>sqlite3
>SQLite version 3.26.0 2018-12-01 12:34:55
>Enter ".help" for usage hints.
>Connected to a transient in-memory database.
>Use ".open FILENAME" to reopen on a persistent database.
>sqlite> select * from pragma_module_list;
>Error: no such table: pragma_module_list
>sqlite> select * from pragma_function_list;
>Error: no such table: pragma_function_list
>sqlite> select * from pragma_compile_options;
>COMPILER=gcc-5.2.0
>ENABLE_DBSTAT_VTAB
>ENABLE_FTS3
>ENABLE_FTS5
>ENABLE_JSON1
>ENABLE_RTREE
>ENABLE_STMTVTAB
>ENABLE_UNKNOWN_SQL_FUNCTION
>THREADSAFE=0



---
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

Reply via email to