diff --git a/plugins/input/sqlite/sqlite_types.hpp b/plugins/input/sqlite/sqlite_types.hpp index ffa9daadf..2e3f6be78 100644 --- a/plugins/input/sqlite/sqlite_types.hpp +++ b/plugins/input/sqlite/sqlite_types.hpp @@ -132,11 +132,19 @@ public: sqlite_connection (const std::string& file) : db_(0) { - #ifdef sqlite3_open_v2 - sqlite3_enable_shared_cache(1); - if (sqlite3_open_v2 (file.c_str(), &db_, SQLITE_OPEN_NOMUTEX|SQLITE_OPEN_SHAREDCACHE, 0)) + // sqlite3_open_v2 is available earlier but + // shared cache not available until >= 3.6.18 + #if SQLITE_VERSION_NUMBER >= 3006018 + int rc = sqlite3_enable_shared_cache(1); + if (rc != SQLITE_OK) + { + throw mapnik::datasource_exception (sqlite3_errmsg (db_)); + } + + int mode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_SHAREDCACHE; + if (sqlite3_open_v2 (file.c_str(), &db_, mode, NULL)) #else - #warning "Mapnik's sqlite plugin is compiling against an old version of sqlite that does no support sqlite3_open_v2 which may make rendering slow..." + #warning "Mapnik's sqlite plugin is compiling against an version of sqlite older than 3.6.18 which may make rendering slow..." if (sqlite3_open (file.c_str(), &db_)) #endif {