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); |