sqlite: fix the ifdef checking so that we actually enable sqlite_open_v2 usages, and also pass the READ mode to avoid undefined behavior - re-closes #797

This commit is contained in:
Dane Springmeyer 2011-08-29 17:46:51 +00:00
parent 8a5e7b9f9a
commit 9446b871f8

View file

@ -132,11 +132,19 @@ public:
sqlite_connection (const std::string& file) sqlite_connection (const std::string& file)
: db_(0) : db_(0)
{ {
#ifdef sqlite3_open_v2 // sqlite3_open_v2 is available earlier but
sqlite3_enable_shared_cache(1); // shared cache not available until >= 3.6.18
if (sqlite3_open_v2 (file.c_str(), &db_, SQLITE_OPEN_NOMUTEX|SQLITE_OPEN_SHAREDCACHE, 0)) #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 #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_)) if (sqlite3_open (file.c_str(), &db_))
#endif #endif
{ {