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

Side by Side Diff: sql/connection.cc

Issue 2830263002: [sql] Remove mmap before Raze(). (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | sql/connection_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sql/connection.h" 5 #include "sql/connection.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 // page, and if it does not match the total retrieved from a 1105 // page, and if it does not match the total retrieved from a
1106 // filesystem call, treats the database as corrupt. This situation 1106 // filesystem call, treats the database as corrupt. This situation
1107 // breaks almost all SQLite calls. "PRAGMA writable_schema" can be 1107 // breaks almost all SQLite calls. "PRAGMA writable_schema" can be
1108 // used to hint to SQLite to soldier on in that case, specifically 1108 // used to hint to SQLite to soldier on in that case, specifically
1109 // for purposes of recovery. [See SQLITE_CORRUPT_BKPT case in 1109 // for purposes of recovery. [See SQLITE_CORRUPT_BKPT case in
1110 // sqlite3.c lockBtree().] 1110 // sqlite3.c lockBtree().]
1111 // TODO(shess): With this, "PRAGMA auto_vacuum" and "PRAGMA 1111 // TODO(shess): With this, "PRAGMA auto_vacuum" and "PRAGMA
1112 // page_size" can be used to query such a database. 1112 // page_size" can be used to query such a database.
1113 ScopedWritableSchema writable_schema(db_); 1113 ScopedWritableSchema writable_schema(db_);
1114 1114
1115 // On Windows, truncate silently fails when applied to memory-mapped files.
1116 // Disable memory-mapping so that the truncate succeeds. Note that other
1117 // connections may have memory-mapped the file, so this may not entirely
1118 // prevent the problem.
pwnall 2017/04/21 11:00:14 Is there any reference for the Windows issue? I sa
Scott Hess - ex-Googler 2017/04/21 14:18:47 I haven't seen anything better than what SQLite sa
pwnall 2017/04/21 19:00:18 Oh, I was under the impression that the same conne
Scott Hess - ex-Googler 2017/04/23 03:36:08 I'm not aware of Raze() cases where the connection
1119 ignore_result(Execute("PRAGMA mmap_size = 0"));
1120
1115 const char* kMain = "main"; 1121 const char* kMain = "main";
1116 int rc = BackupDatabase(null_db.db_, db_, kMain); 1122 int rc = BackupDatabase(null_db.db_, db_, kMain);
1117 UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.RazeDatabase",rc); 1123 UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.RazeDatabase",rc);
1118 1124
1119 // The destination database was locked. 1125 // The destination database was locked.
1120 if (rc == SQLITE_BUSY) { 1126 if (rc == SQLITE_BUSY) {
1121 return false; 1127 return false;
1122 } 1128 }
1123 1129
1124 // SQLITE_NOTADB can happen if page 1 of db_ exists, but is not 1130 // SQLITE_NOTADB can happen if page 1 of db_ exists, but is not
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 const std::string& dump_name) { 2061 const std::string& dump_name) {
2056 return memory_dump_provider_ && 2062 return memory_dump_provider_ &&
2057 memory_dump_provider_->ReportMemoryUsage(pmd, dump_name); 2063 memory_dump_provider_->ReportMemoryUsage(pmd, dump_name);
2058 } 2064 }
2059 2065
2060 base::TimeTicks TimeSource::Now() { 2066 base::TimeTicks TimeSource::Now() {
2061 return base::TimeTicks::Now(); 2067 return base::TimeTicks::Now();
2062 } 2068 }
2063 2069
2064 } // namespace sql 2070 } // namespace sql
OLDNEW
« 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