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:
parent
8a5e7b9f9a
commit
9446b871f8
1 changed files with 12 additions and 4 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue