the pre-packaged 'libsqlite' trap |
SQLite is very quickly evolving; more or less every month they release a new version, and this very easily introduces
some interesting new feature. As a rule of the thumb, SpatiaLite tends to support such cool new options. But even worst, many things absolutely critical for SpatiaLite are quite recent ones: Extensions, VirtualTables, R*Tree ... |
Very often pre-packaged distributions are quite slow to release; so it's very alike you are actually using some really obsolescent
libsqlite version. And this, quite obviously, can cause some form of incompatibility, more or less severe. But all this doesn't tells the full story; we have already to begin the bitter part ... |
SQLite introduced the extension mechanism since version 3.3.6 [June 2006]. So you are allowed to load any available extension simply using the following SQL statement: |
SELECT load_extension('filename'); |
extensions actually are dynamic libraries adopting a conventional interface,
and SQLite implements dynamic loading at run time
simply invoking an SQL statement. Simple and nice, isn't it ? And all this seems to open a very easy way to integrate SpatiaLite (and any other available extension as well) with any existing SQLite wrapper or language binding. Really a smart design, do you agree ? |
NO Very often this solution completely fails, and you'll get some puzzling error. Let examine quite in-depth what is really happening:
|
End of the story ? Not exactly ... In recent times we have lots of pre-packaged distributions intentionally keeping extensions disabled. Reasons accounting for this are easy to explain: security concerns prevail [after all, dynamically load extension may actually allow malicious software to be executed], and on this basis many packagers opt to eradicate the whole sqlite extension mechanism from scratch ... just to feel really sure. |
I personally judge such security concerns to be a little bit paranoid ones. Imagine a malicious hacker attempting to attack your system exploiting Sqlite and its dynamic extensions:
|
Anyway, if this one is your case, I'm really sorry, but there is no possible solution. Since the maintainer of your preferred sqlite-based software doesn't agree to support extensions, you will be completely stuck. There is no way to interoperate such gelded sqlite and extensions; forget using SpatiaLite at all. |
Happily it seems things are slowly going better; I recently tested the latest pysqlite-2 and I discovered it supports SpatiaLite with no problems. Let us hope in the very next future enlightening will prevail over security concerns, so to allow the vast majority of sqlite-related software to support extension (and, consequently, SpatiaLite). |