| Index: sql/connection.cc
|
| diff --git a/sql/connection.cc b/sql/connection.cc
|
| index 510d6a771b4b7598e4f83f6cba68ded7520b3cb0..67cdf0886e8a4a259b00165b91165ce7cb93e4eb 100644
|
| --- a/sql/connection.cc
|
| +++ b/sql/connection.cc
|
| @@ -68,6 +68,28 @@ class ScopedWritableSchema {
|
|
|
| namespace sql {
|
|
|
| +// static
|
| +Connection::ErrorIgnorerCallback* Connection::current_ignorer_cb_ = NULL;
|
| +
|
| +// static
|
| +bool Connection::ShouldIgnore(int error) {
|
| + if (!current_ignorer_cb_)
|
| + return false;
|
| + return current_ignorer_cb_->Run(error);
|
| +}
|
| +
|
| +// static
|
| +void Connection::SetErrorIgnorer(Connection::ErrorIgnorerCallback* cb) {
|
| + CHECK(current_ignorer_cb_ == NULL);
|
| + current_ignorer_cb_ = cb;
|
| +}
|
| +
|
| +// static
|
| +void Connection::ResetErrorIgnorer() {
|
| + CHECK(current_ignorer_cb_);
|
| + current_ignorer_cb_ = NULL;
|
| +}
|
| +
|
| bool StatementID::operator<(const StatementID& other) const {
|
| if (number_ != other.number_)
|
| return number_ < other.number_;
|
| @@ -435,7 +457,8 @@ bool Connection::Execute(const char* sql) {
|
|
|
| // This needs to be a FATAL log because the error case of arriving here is
|
| // that there's a malformed SQL statement. This can arise in development if
|
| - // a change alters the schema but not all queries adjust.
|
| + // a change alters the schema but not all queries adjust. This can happen
|
| + // in production if the schema is corrupted.
|
| if (error == SQLITE_ERROR)
|
| DLOG(FATAL) << "SQL Error in " << sql << ", " << GetErrorMessage();
|
| return error == SQLITE_OK;
|
| @@ -660,11 +683,10 @@ bool Connection::OpenInternal(const std::string& file_name) {
|
| // assumptions about who might change things in the database.
|
| // http://crbug.com/56559
|
| if (exclusive_locking_) {
|
| - // TODO(shess): This should probably be a full CHECK(). Code
|
| - // which requests exclusive locking but doesn't get it is almost
|
| - // certain to be ill-tested.
|
| - if (!Execute("PRAGMA locking_mode=EXCLUSIVE"))
|
| - DLOG(FATAL) << "Could not set locking mode: " << GetErrorMessage();
|
| + // TODO(shess): This should probably be a failure. Code which
|
| + // requests exclusive locking but doesn't get it is almost certain
|
| + // to be ill-tested.
|
| + ignore_result(Execute("PRAGMA locking_mode=EXCLUSIVE"));
|
| }
|
|
|
| // http://www.sqlite.org/pragma.html#pragma_journal_mode
|
| @@ -689,19 +711,16 @@ bool Connection::OpenInternal(const std::string& file_name) {
|
| DCHECK_LE(page_size_, kSqliteMaxPageSize);
|
| const std::string sql =
|
| base::StringPrintf("PRAGMA page_size=%d", page_size_);
|
| - if (!ExecuteWithTimeout(sql.c_str(), kBusyTimeout))
|
| - DLOG(FATAL) << "Could not set page size: " << GetErrorMessage();
|
| + ignore_result(ExecuteWithTimeout(sql.c_str(), kBusyTimeout));
|
| }
|
|
|
| if (cache_size_ != 0) {
|
| const std::string sql =
|
| base::StringPrintf("PRAGMA cache_size=%d", cache_size_);
|
| - if (!ExecuteWithTimeout(sql.c_str(), kBusyTimeout))
|
| - DLOG(FATAL) << "Could not set cache size: " << GetErrorMessage();
|
| + ignore_result(ExecuteWithTimeout(sql.c_str(), kBusyTimeout));
|
| }
|
|
|
| if (!ExecuteWithTimeout("PRAGMA secure_delete=ON", kBusyTimeout)) {
|
| - DLOG(FATAL) << "Could not enable secure_delete: " << GetErrorMessage();
|
| Close();
|
| return false;
|
| }
|
| @@ -761,7 +780,8 @@ int Connection::OnSqliteError(int err, sql::Statement *stmt) {
|
| }
|
|
|
| // The default handling is to assert on debug and to ignore on release.
|
| - DLOG(FATAL) << GetErrorMessage();
|
| + if (!ShouldIgnore(err))
|
| + DLOG(FATAL) << GetErrorMessage();
|
| return err;
|
| }
|
|
|
|
|