This is the first of a series of posts about SQLite extensions, mostly revolving around Unicode string manipulation where non-ASCII characters are involved.
First here is a couple of functions to handle loading .DLL extensions.
I'll do my best to have them included some day in the standard SQLite UDF, as these functions are completely generic and extensions are an excellent (sometimes absolutely required) supplement to this superior tool.Usage:
($hConn, $OnOrOff) to enable or disable extension loading for a given connection. By default, SQLite doesn't allow users to load extension as a security feature. This call is needed before any extension can be loaded.
($hConn, $sFullPath, $sEntry = 'sqlite3_extension_init') to load an extension .dll that will be available to the $nConn connection only. $sEntry is the DLL entry point name. Loading of extensions must have been enabled before.
($sFullPath, $sEntry = 'sqlite3_extension_init') to load an extension .dll that will be available to each new connection only, during the same SQLite session. $sEntry is the DLL entry point name.
There are advantages and drawbacks in both loading and auto-loading extensions. This will be exposed in full detail in the Unifuzz post, any time soon.
I didn't add support to "unload" a function that was loaded as part of an extension. When you load an SQLite extension, you load new functions and/or override existing scalar or collation core functions. It's possible to "forget" custom functions on an individual basis and revert to code functions which have been overriden. I didn't see anyhing healthy in such feature. I consider that if a someone actually needs to use a function on such an intermittent basis, then there's a fundamental design flaw. Anyway, you know the thing is possible. Note that there is as well an SQLite API to unload all auto-extensions. That shouldn't be necessary either.
Almost forgot to add: it is also possible to load certain extensions using SQL: "SELECT load_extension('full path of .dll', 'entry point name');"
But again, loading of extensions need to be allowed beforehand. Warning: not all extensions can be loaded this way. Future post will explain why.
Edited by jchd, 07 March 2010 - 11:13 AM.