fix multiple attach to the same sqlite database

This commit is contained in:
Jiri Drbalek 2014-10-01 12:17:46 +00:00
parent 7c5cdc8e2c
commit b6438a80d1

View file

@ -278,9 +278,11 @@ sqlite_datasource::sqlite_datasource(parameters const& params)
mapnik::progress_timer __stats2__(std::clog, "sqlite_datasource::init(use_spatial_index)"); mapnik::progress_timer __stats2__(std::clog, "sqlite_datasource::init(use_spatial_index)");
#endif #endif
bool index_db_attached = false;
if (mapnik::util::exists(index_db)) if (mapnik::util::exists(index_db))
{ {
dataset_->execute("attach database '" + index_db + "' as " + index_table_); dataset_->execute("attach database '" + index_db + "' as " + index_table_);
index_db_attached = true;
} }
has_spatial_index_ = sqlite_utils::has_rtree(index_table_,dataset_); has_spatial_index_ = sqlite_utils::has_rtree(index_table_,dataset_);
@ -304,7 +306,7 @@ sqlite_datasource::sqlite_datasource(parameters const& params)
{ {
//extent_initialized_ = true; //extent_initialized_ = true;
has_spatial_index_ = true; has_spatial_index_ = true;
if (mapnik::util::exists(index_db)) if (!index_db_attached && mapnik::util::exists(index_db))
{ {
dataset_->execute("attach database '" + index_db + "' as " + index_table_); dataset_->execute("attach database '" + index_db + "' as " + index_table_);
} }