From b6438a80d193f801691bae69e1e124a1a8b59df2 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Wed, 1 Oct 2014 12:17:46 +0000 Subject: [PATCH] fix multiple attach to the same sqlite database --- plugins/input/sqlite/sqlite_datasource.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index fa402d31e..25f727b24 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -278,9 +278,11 @@ sqlite_datasource::sqlite_datasource(parameters const& params) mapnik::progress_timer __stats2__(std::clog, "sqlite_datasource::init(use_spatial_index)"); #endif + bool index_db_attached = false; if (mapnik::util::exists(index_db)) { dataset_->execute("attach database '" + index_db + "' as " + index_table_); + index_db_attached = true; } has_spatial_index_ = sqlite_utils::has_rtree(index_table_,dataset_); @@ -304,7 +306,7 @@ sqlite_datasource::sqlite_datasource(parameters const& params) { //extent_initialized_ = 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_); }