Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: sql/connection.cc

Issue 2830263002: [sql] Remove mmap before Raze(). (Closed)
Patch Set: speeeling Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sql/connection_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/connection.cc
diff --git a/sql/connection.cc b/sql/connection.cc
index 0511e11b5c5b22361bbdf24cc1230203749f272b..c80758f3d6bc102c84794a0c9a4db04d2fad0243 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -1112,6 +1112,15 @@ bool Connection::Raze() {
// page_size" can be used to query such a database.
ScopedWritableSchema writable_schema(db_);
+#if defined(OS_WIN)
+ // On Windows, truncate silently fails when applied to memory-mapped files.
+ // Disable memory-mapping so that the truncate succeeds. Note that other
+ // connections may have memory-mapped the file, so this may not entirely
+ // prevent the problem.
+ // [Source: <https://sqlite.org/mmap.html> plus experiments.]
+ ignore_result(Execute("PRAGMA mmap_size = 0"));
+#endif
+
const char* kMain = "main";
int rc = BackupDatabase(null_db.db_, db_, kMain);
UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.RazeDatabase",rc);
« no previous file with comments | « no previous file | sql/connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698