summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <jason@mapbox.com>2016-09-09 10:40:03 -0400
committerJason Wray <jason@mapbox.com>2016-09-14 15:45:47 -0400
commit4daff7f2f856fa0817a6c316997eb1090290c626 (patch)
tree6ef94d330561246a720005eed271821c163dc464
parentffa8c489260865877fcd4ce6a18b76b810b96327 (diff)
downloadqtlocation-mapboxgl-4daff7f2f856fa0817a6c316997eb1090290c626.tar.gz
[core] Revert SQLite WAL journaling
-rw-r--r--platform/default/mbgl/storage/offline_database.cpp17
-rw-r--r--platform/default/mbgl/storage/offline_database.hpp1
-rw-r--r--test/storage/offline_database.cpp10
3 files changed, 18 insertions, 10 deletions
diff --git a/platform/default/mbgl/storage/offline_database.cpp b/platform/default/mbgl/storage/offline_database.cpp
index d93b1734b4..50e2bdfbc4 100644
--- a/platform/default/mbgl/storage/offline_database.cpp
+++ b/platform/default/mbgl/storage/offline_database.cpp
@@ -49,7 +49,8 @@ void OfflineDatabase::ensureSchema() {
case 1: break; // cache-only database; ok to delete
case 2: migrateToVersion3(); // fall through
case 3: migrateToVersion4(); // fall through
- case 4: return;
+ case 4: migrateToVersion5(); // fall through
+ case 5: return;
default: throw std::runtime_error("unknown schema version");
}
@@ -80,10 +81,10 @@ void OfflineDatabase::ensureSchema() {
// If you change the schema you must write a migration from the previous version.
db->exec("PRAGMA auto_vacuum = INCREMENTAL");
- db->exec("PRAGMA synchronous = NORMAL");
- db->exec("PRAGMA journal_mode = WAL");
+ db->exec("PRAGMA journal_mode = DELETE");
+ db->exec("PRAGMA synchronous = FULL");
db->exec(schema);
- db->exec("PRAGMA user_version = 4");
+ db->exec("PRAGMA user_version = 5");
} catch (...) {
Log::Error(Event::Database, "Unexpected error creating database schema: %s", util::toString(std::current_exception()).c_str());
throw;
@@ -115,11 +116,17 @@ void OfflineDatabase::migrateToVersion3() {
}
void OfflineDatabase::migrateToVersion4() {
- db->exec("PRAGMA synchronous = NORMAL");
db->exec("PRAGMA journal_mode = WAL");
+ db->exec("PRAGMA synchronous = NORMAL");
db->exec("PRAGMA user_version = 4");
}
+void OfflineDatabase::migrateToVersion5() {
+ db->exec("PRAGMA journal_mode = DELETE");
+ db->exec("PRAGMA synchronous = FULL");
+ db->exec("PRAGMA user_version = 5");
+}
+
OfflineDatabase::Statement OfflineDatabase::getStatement(const char * sql) {
auto it = statements.find(sql);
diff --git a/platform/default/mbgl/storage/offline_database.hpp b/platform/default/mbgl/storage/offline_database.hpp
index 00394aa720..5e9a190578 100644
--- a/platform/default/mbgl/storage/offline_database.hpp
+++ b/platform/default/mbgl/storage/offline_database.hpp
@@ -61,6 +61,7 @@ private:
void removeExisting();
void migrateToVersion3();
void migrateToVersion4();
+ void migrateToVersion5();
class Statement {
public:
diff --git a/test/storage/offline_database.cpp b/test/storage/offline_database.cpp
index bcea3cd8f3..3ce42cdba0 100644
--- a/test/storage/offline_database.cpp
+++ b/test/storage/offline_database.cpp
@@ -559,18 +559,18 @@ TEST(OfflineDatabase, MigrateFromV2Schema) {
// v2.db is a v2 database containing a single offline region with a small number of resources.
- deleteFile("test/fixtures/offline_database/v4.db");
- writeFile("test/fixtures/offline_database/v4.db", util::read_file("test/fixtures/offline_database/v2.db"));
+ deleteFile("test/fixtures/offline_database/v5.db");
+ writeFile("test/fixtures/offline_database/v5.db", util::read_file("test/fixtures/offline_database/v2.db"));
{
- OfflineDatabase db("test/fixtures/offline_database/v4.db", 0);
+ OfflineDatabase db("test/fixtures/offline_database/v5.db", 0);
auto regions = db.listRegions();
for (auto& region : regions) {
db.deleteRegion(std::move(region));
}
}
- EXPECT_EQ(4, databaseUserVersion("test/fixtures/offline_database/v4.db"));
- EXPECT_LT(databasePageCount("test/fixtures/offline_database/v4.db"),
+ EXPECT_EQ(5, databaseUserVersion("test/fixtures/offline_database/v5.db"));
+ EXPECT_LT(databasePageCount("test/fixtures/offline_database/v5.db"),
databasePageCount("test/fixtures/offline_database/v2.db"));
}