artemp/trac2github — Issue #794: Support attachdb, initdb, and index_table parameters in sqlite plugin
Author: artemp
Created: 2011-10-09 20:51:20+00:00
State: open
Labels: SQLite_Input_Driver

The sqlite input plugin currently has no way to attach auxiliary databases (see SQLite ATTACH DATABASE command). SQLite manages attached databases on a per-connection basis. Therefore, any component that opens a SQLite database needs to have the ability to issue one or more ATTACH DATABASE commands on connect in order to restore multi-database datasources to a usable state.

This patch adds an attachdb parameter and generalizes this support with an additional initdb parameter. Also, some existing code for determining the index table name was cleaned up so that index table names can now be specified explicitly with the index_table parameter.

New Parameters:

* attachdb (syntax: dbname1@dbfile1[,dbname2@dbfile2...]): Attach one or more database files as the given database names to the session. Special care is taken to ensure that if any of the dbfiles are relative, they are resolved relative to the primary database file (as specified in the file parameter). This ensures that database clusters are relocatable on the file system.
* initdb (syntax: sql1[;sql2...]): If specified, the contents of this parameter are passed to the SQLite exec function just after any ATTACH DATABASE statements that result from the attachdb parameter. Mapnik does no parsing of the value. It is passed to SQLite as-is.
* index_table: If present, then this overrides the default logic for the naming of the SQLite RTREE table that serves as the index. If empty or omitted, the default is "idx_{geometry_table}_{geometry_column}".

Tests have also been added that verify each of these initialization paths.