[GRASS-dev] How to calculate log() in v.db.update with SQLite backend?

Moritz Lennert mlennert at club.worldonline.be
Thu Nov 20 00:22:58 PST 2014


On 20/11/14 08:46, Moritz Lennert wrote:
> On 19/11/14 19:12, Vaclav Petras wrote:
>>
>> On Wed, Nov 19, 2014 at 12:59 PM, Markus Neteler <neteler at osgeo.org
>> <mailto:neteler at osgeo.org>> wrote:
>>
>>
>>     DBMI-SQLite driver error:
>>     Error in sqlite3_step():
>>     not authorized
>>
>>     ERROR: Error while executing: 'SELECT
>>
>>
>> load_extension('/home/neteler/software/sqlite_extensions/libsqlitefunctions.so')'
>>
>>     Traceback (most recent call last):
>>     ...
>>     Process ended with non-zero return code 1. See errors in the (error)
>>     output.
>>
>>     No idea what's disliked here in:
>>
>>     SELECT
>>
>> load_extension('/home/neteler/software/sqlite_extensions/libsqlitefunctions.so');
>>
>>     UPDATE meuse_voronoi SET logzinc=log(zinc);
>>
>>     Any hints?
>>
>>
>> Loading user defined function is not considered completely safe, so it
>> is disabled by default. I think this is not an issue for GRASS GIS.
>>
>> You have to enable it somehow. It seems that enable_load_extension() is
>> the way.
>
> Right.
>
> But this depends on the installation, i.e. how sqlite3 was compiled.
> Here in Debian Testing I do not need to activate anything, so I assume
> that it's activated by default.

However, I'm not sure if sqlite needs to be compiled with this option by 
default. I think we could activate it in the sqlite driver.

Below is a proposal after a very superficial reading of the docs and 
code, so no guarantees (and I cannot really test here since it seems 
enabled by default).

However, this means that we enable this automatically for each sqlite db 
opened by GRASS...

Moritz

Index: db/drivers/sqlite/db.c
===================================================================
--- db/drivers/sqlite/db.c	(révision 62792)
+++ db/drivers/sqlite/db.c	(copie de travail)
@@ -110,6 +110,9 @@
  	return DB_FAILED;
      }

+    /* enable loading of extensions */
+    sqlite3_enable_load_extension(sqlite, 1);
+
      /* set the sqlite busy handler */
      sqlite3_busy_handler(sqlite, sqlite_busy_callback, NULL);



More information about the grass-dev mailing list