summaryrefslogtreecommitdiffstats
path: root/sql/connection.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/connection.cc')
-rw-r--r--sql/connection.cc31
1 files changed, 19 insertions, 12 deletions
diff --git a/sql/connection.cc b/sql/connection.cc
index a904632..79264916 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -1628,18 +1628,6 @@ bool Connection::OpenInternal(const std::string& file_name,
// secure_delete.
ignore_result(Execute("PRAGMA journal_mode = TRUNCATE"));
- // Enable memory-mapped access. This value will be capped by
- // SQLITE_MAX_MMAP_SIZE, which could be different between 32-bit and 64-bit
- // platforms.
- mmap_enabled_ = false;
- if (!mmap_disabled_)
- ignore_result(Execute("PRAGMA mmap_size = 268435456")); // 256MB.
- {
- Statement s(GetUniqueStatement("PRAGMA mmap_size"));
- if (s.Step() && s.ColumnInt64(0) > 0)
- mmap_enabled_ = true;
- }
-
const base::TimeDelta kBusyTimeout =
base::TimeDelta::FromSeconds(kBusyTimeoutSeconds);
@@ -1668,6 +1656,25 @@ bool Connection::OpenInternal(const std::string& file_name,
return false;
}
+ // Enable memory-mapped access. The explicit-disable case is because SQLite
+ // can be built to default-enable mmap. This value will be capped by
+ // SQLITE_MAX_MMAP_SIZE, which could be different between 32-bit and 64-bit
+ // platforms.
+ if (mmap_disabled_) {
+ ignore_result(Execute("PRAGMA mmap_size = 0"));
+ } else {
+ ignore_result(Execute("PRAGMA mmap_size = 268435456")); // 256MB.
+ }
+
+ // Determine if memory-mapping has actually been enabled. The Execute() above
+ // can succeed without changing the amount mapped.
+ mmap_enabled_ = false;
+ {
+ Statement s(GetUniqueStatement("PRAGMA mmap_size"));
+ if (s.Step() && s.ColumnInt64(0) > 0)
+ mmap_enabled_ = true;
+ }
+
return true;
}