forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: Remove sql::Database default constructor use from sql::Database.
Bug: 1126968 Change-Id: I5f1537d05f8dc23c543f410babcfa598f18b4c02 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2914310 Commit-Queue: Ayu Ishii <[email protected]> Auto-Submit: Victor Costan <[email protected]> Reviewed-by: Ayu Ishii <[email protected]> Cr-Commit-Position: refs/heads/master@{#886031}
- Loading branch information
Showing
1 changed file
with
9 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ | |
#include "base/no_destructor.h" | ||
#include "base/numerics/safe_conversions.h" | ||
#include "base/single_thread_task_runner.h" | ||
#include "base/strings/strcat.h" | ||
#include "base/strings/string_number_conversions.h" | ||
#include "base/strings/string_split.h" | ||
#include "base/strings/string_util.h" | ||
#include "base/strings/stringprintf.h" | ||
|
@@ -807,17 +809,16 @@ bool Database::Raze() { | |
return false; | ||
} | ||
|
||
sql::Database null_db; | ||
sql::Database null_db(sql::DatabaseOptions{ | ||
.exclusive_locking = true, | ||
.page_size = options_.page_size, | ||
.cache_size = 0, | ||
}); | ||
if (!null_db.OpenInMemory()) { | ||
DLOG(DCHECK) << "Unable to open in-memory database."; | ||
return false; | ||
} | ||
|
||
const std::string page_size_sql = | ||
base::StringPrintf("PRAGMA page_size=%d", options_.page_size); | ||
if (!null_db.Execute(page_size_sql.c_str())) | ||
return false; | ||
|
||
#if defined(OS_ANDROID) | ||
// Android compiles with SQLITE_DEFAULT_AUTOVACUUM. Unfortunately, | ||
// in-memory databases do not respect this define. | ||
|
@@ -901,6 +902,8 @@ bool Database::Raze() { | |
// TODO([email protected]): Need a guarantee here that there is no other | ||
// database connection open. | ||
ignore_result(Execute("PRAGMA journal_mode=TRUNCATE;")); | ||
const std::string page_size_sql = base::StrCat( | ||
{"PRAGMA page_size=", base::NumberToString(options_.page_size)}); | ||
if (!Execute(page_size_sql.c_str())) { | ||
return false; | ||
} | ||
|