summaryrefslogtreecommitdiff
path: root/chromium/sql
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-07-16 11:45:35 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-07-17 08:59:23 +0000
commit552906b0f222c5d5dd11b9fd73829d510980461a (patch)
tree3a11e6ed0538a81dd83b20cf3a4783e297f26d91 /chromium/sql
parent1b05827804eaf047779b597718c03e7d38344261 (diff)
downloadqtwebengine-chromium-552906b0f222c5d5dd11b9fd73829d510980461a.tar.gz
BASELINE: Update Chromium to 83.0.4103.122
Change-Id: Ie3a82f5bb0076eec2a7c6a6162326b4301ee291e Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/sql')
-rw-r--r--chromium/sql/BUILD.gn18
-rw-r--r--chromium/sql/database.cc68
-rw-r--r--chromium/sql/database.h14
-rw-r--r--chromium/sql/statement.cc4
-rw-r--r--chromium/sql/statement.h1
5 files changed, 75 insertions, 30 deletions
diff --git a/chromium/sql/BUILD.gn b/chromium/sql/BUILD.gn
index f4deebead7a..119f16403b4 100644
--- a/chromium/sql/BUILD.gn
+++ b/chromium/sql/BUILD.gn
@@ -87,9 +87,7 @@ static_library("test_support") {
"test/test_helpers.h",
]
- public_deps = [
- ":sql",
- ]
+ public_deps = [ ":sql" ]
deps = [
"//base",
"//testing/gtest",
@@ -99,13 +97,9 @@ static_library("test_support") {
bundle_data("sql_unittests_bundle_data") {
testonly = true
- sources = [
- "test/data/recovery_387868",
- ]
- outputs = [
- "{{bundle_resources_dir}}/" +
- "{{source_root_relative_dir}}/{{source_file_part}}",
- ]
+ sources = [ "test/data/recovery_387868" ]
+ outputs = [ "{{bundle_resources_dir}}/" +
+ "{{source_root_relative_dir}}/{{source_file_part}}" ]
}
test("sql_unittests") {
@@ -130,9 +124,7 @@ test("sql_unittests") {
"transaction_unittest.cc",
]
- data = [
- "test/data/",
- ]
+ data = [ "test/data/" ]
deps = [
":sql",
diff --git a/chromium/sql/database.cc b/chromium/sql/database.cc
index 7f7bcd2a830..eeab5e626c2 100644
--- a/chromium/sql/database.cc
+++ b/chromium/sql/database.cc
@@ -27,6 +27,7 @@
#include "base/synchronization/lock.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "sql/database_memory_dump_provider.h"
#include "sql/initialization.h"
@@ -217,7 +218,7 @@ void Database::StatementRef::Close(bool forced) {
// TODO(paivanof@gmail.com): This should move to the beginning
// of the function. http://crbug.com/136655.
base::Optional<base::ScopedBlockingCall> scoped_blocking_call;
- InitScopedBlockingCall(&scoped_blocking_call);
+ InitScopedBlockingCall(FROM_HERE, &scoped_blocking_call);
sqlite3_finalize(stmt_);
stmt_ = nullptr;
}
@@ -267,19 +268,23 @@ void Database::RecordEvent(Events event, size_t count) {
}
bool Database::Open(const base::FilePath& path) {
+ TRACE_EVENT1("sql", "Database::Open", "path", path.MaybeAsASCII());
return OpenInternal(AsUTF8ForSQL(path), RETRY_ON_POISON);
}
bool Database::OpenInMemory() {
+ TRACE_EVENT0("sql", "Database::OpenInMemory");
in_memory_ = true;
return OpenInternal(":memory:", NO_RETRY);
}
bool Database::OpenTemporary() {
+ TRACE_EVENT0("sql", "Database::OpenTemporary");
return OpenInternal("", NO_RETRY);
}
void Database::CloseInternal(bool forced) {
+ TRACE_EVENT0("sql", "Database::CloseInternal");
// TODO(shess): Calling "PRAGMA journal_mode = DELETE" at this point
// will delete the -journal file. For ChromiumOS or other more
// embedded systems, this is probably not appropriate, whereas on
@@ -309,9 +314,9 @@ void Database::CloseInternal(bool forced) {
// TODO(paivanof@gmail.com): This should move to the beginning
// of the function. http://crbug.com/136655.
base::Optional<base::ScopedBlockingCall> scoped_blocking_call;
- InitScopedBlockingCall(&scoped_blocking_call);
+ InitScopedBlockingCall(FROM_HERE, &scoped_blocking_call);
- // Reseting acquires a lock to ensure no dump is happening on the database
+ // Resetting acquires a lock to ensure no dump is happening on the database
// at the same time. Unregister takes ownership of provider and it is safe
// since the db is reset. memory_dump_provider_ could be null if db_ was
// poisoned.
@@ -332,6 +337,7 @@ void Database::CloseInternal(bool forced) {
}
void Database::Close() {
+ TRACE_EVENT0("sql", "Database::Close");
// If the database was already closed by RazeAndClose(), then no
// need to close again. Clear the |poisoned_| bit so that incorrect
// API calls are caught.
@@ -344,6 +350,7 @@ void Database::Close() {
}
void Database::Preload() {
+ TRACE_EVENT0("sql", "Database::Preload");
if (base::FeatureList::IsEnabled(features::kSqlSkipPreload))
return;
@@ -353,7 +360,7 @@ void Database::Preload() {
}
base::Optional<base::ScopedBlockingCall> scoped_blocking_call;
- InitScopedBlockingCall(&scoped_blocking_call);
+ InitScopedBlockingCall(FROM_HERE, &scoped_blocking_call);
// Maximum number of bytes that will be prefetched from the database.
//
@@ -410,6 +417,7 @@ void Database::Preload() {
// false. The downside then is that it allows open-ended use of memory for
// large transactions.
void Database::ReleaseCacheMemoryIfNeeded(bool implicit_change_performed) {
+ TRACE_EVENT0("sql", "Database::ReleaseCacheMemoryIfNeeded");
// The database could have been closed during a transaction as part of error
// recovery.
if (!db_) {
@@ -458,6 +466,7 @@ base::FilePath Database::DbPath() const {
}
std::string Database::CollectErrorInfo(int error, Statement* stmt) const {
+ TRACE_EVENT0("sql", "Database::CollectErrorInfo");
// Buffer for accumulating debugging info about the error. Place
// more-relevant information earlier, in case things overflow the
// fixed-size reporting buffer.
@@ -552,6 +561,7 @@ std::string Database::CollectErrorInfo(int error, Statement* stmt) const {
// TODO(shess): Since this is only called in an error situation, it might be
// prudent to rewrite in terms of SQLite API calls, and mark the function const.
std::string Database::CollectCorruptionInfo() {
+ TRACE_EVENT0("sql", "Database::CollectCorruptionInfo");
// If the file cannot be accessed it is unlikely that an integrity check will
// turn up actionable information.
const base::FilePath db_path = DbPath();
@@ -593,6 +603,8 @@ std::string Database::CollectCorruptionInfo() {
}
bool Database::GetMmapAltStatus(int64_t* status) {
+ TRACE_EVENT0("sql", "Database::GetMmapAltStatus");
+
// The [meta] version uses a missing table as a signal for a fresh database.
// That will not work for the view, which would not exist in either a new or
// an existing database. A new database _should_ be only one page long, so
@@ -635,8 +647,10 @@ bool Database::SetMmapAltStatus(int64_t status) {
}
size_t Database::GetAppropriateMmapSize() {
+ TRACE_EVENT0("sql", "Database::GetAppropriateMmapSize");
+
base::Optional<base::ScopedBlockingCall> scoped_blocking_call;
- InitScopedBlockingCall(&scoped_blocking_call);
+ InitScopedBlockingCall(FROM_HERE, &scoped_blocking_call);
// How much to map if no errors are found. 50MB encompasses the 99th
// percentile of Chrome databases in the wild, so this should be good.
@@ -759,6 +773,8 @@ size_t Database::GetAppropriateMmapSize() {
}
void Database::TrimMemory() {
+ TRACE_EVENT0("sql", "Database::TrimMemory");
+
if (!db_)
return;
@@ -776,8 +792,10 @@ void Database::TrimMemory() {
// Create an in-memory database with the existing database's page
// size, then backup that database over the existing database.
bool Database::Raze() {
+ TRACE_EVENT0("sql", "Database::Raze");
+
base::Optional<base::ScopedBlockingCall> scoped_blocking_call;
- InitScopedBlockingCall(&scoped_blocking_call);
+ InitScopedBlockingCall(FROM_HERE, &scoped_blocking_call);
if (!db_) {
DCHECK(poisoned_) << "Cannot raze null db";
@@ -884,6 +902,8 @@ bool Database::Raze() {
}
bool Database::RazeAndClose() {
+ TRACE_EVENT0("sql", "Database::RazeAndClose");
+
if (!db_) {
DCHECK(poisoned_) << "Cannot raze null db";
return false;
@@ -905,6 +925,8 @@ bool Database::RazeAndClose() {
}
void Database::Poison() {
+ TRACE_EVENT0("sql", "Database::Poison");
+
if (!db_) {
DCHECK(poisoned_) << "Cannot poison null db";
return;
@@ -931,6 +953,8 @@ void Database::Poison() {
//
// static
bool Database::Delete(const base::FilePath& path) {
+ TRACE_EVENT1("sql", "Database::Delete", "path", path.MaybeAsASCII());
+
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
@@ -971,6 +995,8 @@ bool Database::Delete(const base::FilePath& path) {
}
bool Database::BeginTransaction() {
+ TRACE_EVENT0("sql", "Database::BeginTransaction");
+
if (needs_rollback_) {
DCHECK_GT(transaction_nesting_, 0);
@@ -992,6 +1018,8 @@ bool Database::BeginTransaction() {
}
void Database::RollbackTransaction() {
+ TRACE_EVENT0("sql", "Database::RollbackTransaction");
+
if (!transaction_nesting_) {
DCHECK(poisoned_) << "Rolling back a nonexistent transaction";
return;
@@ -1009,6 +1037,8 @@ void Database::RollbackTransaction() {
}
bool Database::CommitTransaction() {
+ TRACE_EVENT0("sql", "Database::CommitTransaction");
+
if (!transaction_nesting_) {
DCHECK(poisoned_) << "Committing a nonexistent transaction";
return false;
@@ -1036,6 +1066,8 @@ bool Database::CommitTransaction() {
}
void Database::RollbackAllTransactions() {
+ TRACE_EVENT0("sql", "Database::RollbackAllTransactions");
+
if (transaction_nesting_ > 0) {
transaction_nesting_ = 0;
DoRollback();
@@ -1045,6 +1077,8 @@ void Database::RollbackAllTransactions() {
bool Database::AttachDatabase(const base::FilePath& other_db_path,
const char* attachment_point,
InternalApiToken) {
+ TRACE_EVENT0("sql", "Database::AttachDatabase");
+
DCHECK(ValidAttachmentPoint(attachment_point));
Statement s(GetUniqueStatement("ATTACH DATABASE ? AS ?"));
@@ -1060,6 +1094,8 @@ bool Database::AttachDatabase(const base::FilePath& other_db_path,
}
bool Database::DetachDatabase(const char* attachment_point, InternalApiToken) {
+ TRACE_EVENT0("sql", "Database::DetachDatabase");
+
DCHECK(ValidAttachmentPoint(attachment_point));
Statement s(GetUniqueStatement("DETACH DATABASE ?"));
@@ -1071,6 +1107,8 @@ bool Database::DetachDatabase(const char* attachment_point, InternalApiToken) {
// caller wishes to execute multiple statements, that should be explicit, and
// perhaps tucked into an explicit transaction with rollback in case of error.
int Database::ExecuteAndReturnErrorCode(const char* sql) {
+ TRACE_EVENT0("sql", "Database::ExecuteAndReturnErrorCode");
+
DCHECK(sql);
if (!db_) {
@@ -1079,7 +1117,7 @@ int Database::ExecuteAndReturnErrorCode(const char* sql) {
}
base::Optional<base::ScopedBlockingCall> scoped_blocking_call;
- InitScopedBlockingCall(&scoped_blocking_call);
+ InitScopedBlockingCall(FROM_HERE, &scoped_blocking_call);
int rc = SQLITE_OK;
while ((rc == SQLITE_OK) && *sql) {
@@ -1127,6 +1165,8 @@ int Database::ExecuteAndReturnErrorCode(const char* sql) {
}
bool Database::Execute(const char* sql) {
+ TRACE_EVENT1("sql", "Database::Execute", "query", TRACE_STR_COPY(sql));
+
if (!db_) {
DCHECK(poisoned_) << "Illegal use of Database without a db";
return false;
@@ -1146,6 +1186,8 @@ bool Database::Execute(const char* sql) {
}
bool Database::ExecuteWithTimeout(const char* sql, base::TimeDelta timeout) {
+ TRACE_EVENT0("sql", "Database::ExecuteWithTimeout");
+
if (!db_) {
DCHECK(poisoned_) << "Illegal use of Database without a db";
return false;
@@ -1198,7 +1240,7 @@ scoped_refptr<Database::StatementRef> Database::GetStatementImpl(
return base::MakeRefCounted<StatementRef>(nullptr, nullptr, poisoned_);
base::Optional<base::ScopedBlockingCall> scoped_blocking_call;
- InitScopedBlockingCall(&scoped_blocking_call);
+ InitScopedBlockingCall(FROM_HERE, &scoped_blocking_call);
// TODO(pwnall): Cached statements (but not unique statements) should be
// prepared with prepFlags set to SQLITE_PREPARE_PERSISTENT.
@@ -1247,7 +1289,7 @@ std::string Database::GetSchema() const {
bool Database::IsSQLValid(const char* sql) {
base::Optional<base::ScopedBlockingCall> scoped_blocking_call;
- InitScopedBlockingCall(&scoped_blocking_call);
+ InitScopedBlockingCall(FROM_HERE, &scoped_blocking_call);
if (!db_) {
DCHECK(poisoned_) << "Illegal use of Database without a db";
return false;
@@ -1346,13 +1388,15 @@ const char* Database::GetErrorMessage() const {
bool Database::OpenInternal(const std::string& file_name,
Database::Retry retry_flag) {
+ TRACE_EVENT1("sql", "Database::OpenInternal", "path", file_name);
+
if (db_) {
DLOG(DCHECK) << "sql::Database is already open.";
return false;
}
base::Optional<base::ScopedBlockingCall> scoped_blocking_call;
- InitScopedBlockingCall(&scoped_blocking_call);
+ InitScopedBlockingCall(FROM_HERE, &scoped_blocking_call);
EnsureSqliteInitialized();
@@ -1521,6 +1565,8 @@ bool Database::OpenInternal(const std::string& file_name,
}
void Database::DoRollback() {
+ TRACE_EVENT0("sql", "Database::DoRollback");
+
Statement rollback(GetCachedStatement(SQL_FROM_HERE, "ROLLBACK"));
rollback.Run();
@@ -1569,6 +1615,8 @@ void Database::AddTaggedHistogram(const std::string& name, int sample) const {
int Database::OnSqliteError(int err,
sql::Statement* stmt,
const char* sql) const {
+ TRACE_EVENT0("sql", "Database::OnSqliteError");
+
base::UmaHistogramSparse("Sqlite.Error", err);
AddTaggedHistogram("Sqlite.Error", err);
diff --git a/chromium/sql/database.h b/chromium/sql/database.h
index ccb1dad3b5e..18ccdcd7d3d 100644
--- a/chromium/sql/database.h
+++ b/chromium/sql/database.h
@@ -129,7 +129,7 @@ class COMPONENT_EXPORT(SQL) Database {
// histogram is recorded.
void AddTaggedHistogram(const std::string& name, int sample) const;
- // Track various API calls and results. Values corrospond to UMA
+ // Track various API calls and results. Values correspond to UMA
// histograms, do not modify, or add or delete other than directly
// before EVENT_MAX_VALUE.
enum Events {
@@ -520,11 +520,13 @@ class COMPONENT_EXPORT(SQL) Database {
void CloseInternal(bool forced);
// Construct a ScopedBlockingCall to annotate IO calls, but only if
- // database wasn't open in memory.
+ // database wasn't open in memory. ScopedBlockingCall uses |from_here| to
+ // declare its blocking execution scope (see https://www.crbug/934302).
void InitScopedBlockingCall(
+ const base::Location& from_here,
base::Optional<base::ScopedBlockingCall>* scoped_blocking_call) const {
if (!in_memory_)
- scoped_blocking_call->emplace(FROM_HERE, base::BlockingType::MAY_BLOCK);
+ scoped_blocking_call->emplace(from_here, base::BlockingType::MAY_BLOCK);
}
// Internal helper for Does*Exist() functions.
@@ -588,11 +590,13 @@ class COMPONENT_EXPORT(SQL) Database {
void Close(bool forced);
// Construct a ScopedBlockingCall to annotate IO calls, but only if
- // database wasn't open in memory.
+ // database wasn't open in memory. ScopedBlockingCall uses |from_here| to
+ // declare its blocking execution scope (see https://www.crbug/934302).
void InitScopedBlockingCall(
+ const base::Location& from_here,
base::Optional<base::ScopedBlockingCall>* scoped_blocking_call) const {
if (database_)
- database_->InitScopedBlockingCall(scoped_blocking_call);
+ database_->InitScopedBlockingCall(from_here, scoped_blocking_call);
}
private:
diff --git a/chromium/sql/statement.cc b/chromium/sql/statement.cc
index 372b28949ab..b49e47bdcc5 100644
--- a/chromium/sql/statement.cc
+++ b/chromium/sql/statement.cc
@@ -58,7 +58,7 @@ int Statement::StepInternal() {
return SQLITE_ERROR;
base::Optional<base::ScopedBlockingCall> scoped_blocking_call;
- ref_->InitScopedBlockingCall(&scoped_blocking_call);
+ ref_->InitScopedBlockingCall(FROM_HERE, &scoped_blocking_call);
stepped_ = true;
int ret = sqlite3_step(ref_->stmt());
@@ -76,7 +76,7 @@ bool Statement::Step() {
void Statement::Reset(bool clear_bound_vars) {
base::Optional<base::ScopedBlockingCall> scoped_blocking_call;
- ref_->InitScopedBlockingCall(&scoped_blocking_call);
+ ref_->InitScopedBlockingCall(FROM_HERE, &scoped_blocking_call);
if (is_valid()) {
if (clear_bound_vars)
sqlite3_clear_bindings(ref_->stmt());
diff --git a/chromium/sql/statement.h b/chromium/sql/statement.h
index 6144b23af14..6983e2132ae 100644
--- a/chromium/sql/statement.h
+++ b/chromium/sql/statement.h
@@ -106,6 +106,7 @@ class COMPONENT_EXPORT(SQL) Statement {
bool BindNull(int col);
bool BindBool(int col, bool val);
bool BindInt(int col, int val);
+ bool BindInt(int col, int64_t val) = delete; // Call BindInt64() instead.
bool BindInt64(int col, int64_t val);
bool BindDouble(int col, double val);
bool BindCString(int col, const char* val);