Skip to content

Commit

Permalink
sql: Remove sql::Database default constructor use from sql::Database.
Browse files Browse the repository at this point in the history
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
pwnall authored and Chromium LUCI CQ committed May 24, 2021
1 parent f73ff21 commit 15aa757
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions sql/database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 15aa757

Please sign in to comment.