summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2013-09-26 13:24:57 +0100
committerTorne (Richard Coles) <torne@google.com>2013-09-26 13:24:57 +0100
commit68043e1e95eeb07d5cae7aca370b26518b0867d6 (patch)
treecc6a216bce6aa9319a216327b73a07f49200dab5 /sql
parentcede44592cfb9ec370925d10c2df733349a94a82 (diff)
downloadchromium_org-68043e1e95eeb07d5cae7aca370b26518b0867d6.tar.gz
Merge from Chromium at DEPS revision 225410
This commit was generated by merge_to_master.py. Change-Id: Ifa1539ca216abb163295ee7a77f81bb67f52e178
Diffstat (limited to 'sql')
-rw-r--r--sql/connection.cc4
-rw-r--r--sql/connection.h7
-rw-r--r--sql/recovery.cc19
-rw-r--r--sql/recovery.h10
-rw-r--r--sql/sql.target.darwin-arm.mk2
-rw-r--r--sql/sql.target.darwin-mips.mk2
-rw-r--r--sql/sql.target.darwin-x86.mk2
-rw-r--r--sql/sql.target.linux-arm.mk2
-rw-r--r--sql/sql.target.linux-mips.mk2
-rw-r--r--sql/sql.target.linux-x86.mk2
10 files changed, 36 insertions, 16 deletions
diff --git a/sql/connection.cc b/sql/connection.cc
index 097edd7a1e..0b49786e72 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -133,7 +133,7 @@ namespace sql {
Connection::ErrorIgnorerCallback* Connection::current_ignorer_cb_ = NULL;
// static
-bool Connection::ShouldIgnore(int error) {
+bool Connection::ShouldIgnoreSqliteError(int error) {
if (!current_ignorer_cb_)
return false;
return current_ignorer_cb_->Run(error);
@@ -1040,7 +1040,7 @@ int Connection::OnSqliteError(int err, sql::Statement *stmt) {
}
// The default handling is to assert on debug and to ignore on release.
- if (!ShouldIgnore(err))
+ if (!ShouldIgnoreSqliteError(err))
DLOG(FATAL) << GetErrorMessage();
return err;
}
diff --git a/sql/connection.h b/sql/connection.h
index 7938606422..5475a84ef5 100644
--- a/sql/connection.h
+++ b/sql/connection.h
@@ -394,6 +394,12 @@ class SQL_EXPORT Connection {
// SELECT type, name, tbl_name, sql FROM sqlite_master ORDER BY 1, 2, 3, 4;
std::string GetSchema() const;
+ // Clients which provide an error_callback don't see the
+ // error-handling at the end of OnSqliteError(). Expose to allow
+ // those clients to work appropriately with ScopedErrorIgnorer in
+ // tests.
+ static bool ShouldIgnoreSqliteError(int error);
+
private:
// For recovery module.
friend class Recovery;
@@ -436,7 +442,6 @@ class SQL_EXPORT Connection {
// See test/scoped_error_ignorer.h.
typedef base::Callback<bool(int)> ErrorIgnorerCallback;
static ErrorIgnorerCallback* current_ignorer_cb_;
- static bool ShouldIgnore(int error);
static void SetErrorIgnorer(ErrorIgnorerCallback* ignorer);
static void ResetErrorIgnorer();
diff --git a/sql/recovery.cc b/sql/recovery.cc
index 9016f8a7ef..fc676613c8 100644
--- a/sql/recovery.cc
+++ b/sql/recovery.cc
@@ -37,6 +37,13 @@ void Recovery::Unrecoverable(scoped_ptr<Recovery> r) {
// ~Recovery() will RAZE_AND_POISON.
}
+// static
+void Recovery::Rollback(scoped_ptr<Recovery> r) {
+ // TODO(shess): HISTOGRAM to track? Or just have people crash out?
+ // Crash and dump?
+ r->Shutdown(POISON);
+}
+
Recovery::Recovery(Connection* connection)
: db_(connection),
recover_db_() {
@@ -69,6 +76,18 @@ bool Recovery::Init(const base::FilePath& db_path) {
// more complicated.
db_->RollbackAllTransactions();
+ // Disable exclusive locking mode so that the attached database can
+ // access things. The locking_mode change is not active until the
+ // next database access, so immediately force an access. Enabling
+ // writable_schema allows processing through certain kinds of
+ // corruption.
+ // TODO(shess): It would be better to just close the handle, but it
+ // is necessary for the final backup which rewrites things. It
+ // might be reasonable to close then re-open the handle.
+ ignore_result(db_->Execute("PRAGMA writable_schema=1"));
+ ignore_result(db_->Execute("PRAGMA locking_mode=NORMAL"));
+ ignore_result(db_->Execute("SELECT COUNT(*) FROM sqlite_master"));
+
if (!recover_db_.OpenTemporary())
return false;
diff --git a/sql/recovery.h b/sql/recovery.h
index c0bb6da236..e832da6001 100644
--- a/sql/recovery.h
+++ b/sql/recovery.h
@@ -64,7 +64,7 @@ class SQL_EXPORT Recovery {
// If Recovered() is not called, the destructor will call
// Unrecoverable().
//
- // TODO(shess): At this time, this function an fail while leaving
+ // TODO(shess): At this time, this function can fail while leaving
// the original database intact. Figure out which failure cases
// should go to RazeAndClose() instead.
static bool Recovered(scoped_ptr<Recovery> r) WARN_UNUSED_RESULT;
@@ -73,6 +73,14 @@ class SQL_EXPORT Recovery {
// database is razed, and the handle poisoned.
static void Unrecoverable(scoped_ptr<Recovery> r);
+ // When initially developing recovery code, sometimes the possible
+ // database states are not well-understood without further
+ // diagnostics. Abandon recovery but do not raze the original
+ // database.
+ // NOTE(shess): Only call this when adding recovery support. In the
+ // steady state, all databases should progress to recovered or razed.
+ static void Rollback(scoped_ptr<Recovery> r);
+
// Handle to the temporary recovery database.
sql::Connection* db() { return &recover_db_; }
diff --git a/sql/sql.target.darwin-arm.mk b/sql/sql.target.darwin-arm.mk
index f837e1af6b..b8fe26c273 100644
--- a/sql/sql.target.darwin-arm.mk
+++ b/sql/sql.target.darwin-arm.mk
@@ -66,7 +66,6 @@ MY_CFLAGS_Debug := \
MY_DEFS_Debug := \
'-DANGLE_DX11' \
- '-DWTF_VECTOR_INITIAL_SIZE=4' \
'-D_FILE_OFFSET_BITS=64' \
'-DNO_TCMALLOC' \
'-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \
@@ -152,7 +151,6 @@ MY_CFLAGS_Release := \
MY_DEFS_Release := \
'-DANGLE_DX11' \
- '-DWTF_VECTOR_INITIAL_SIZE=4' \
'-D_FILE_OFFSET_BITS=64' \
'-DNO_TCMALLOC' \
'-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \
diff --git a/sql/sql.target.darwin-mips.mk b/sql/sql.target.darwin-mips.mk
index 6abc4f751c..1cf0ccf0af 100644
--- a/sql/sql.target.darwin-mips.mk
+++ b/sql/sql.target.darwin-mips.mk
@@ -65,7 +65,6 @@ MY_CFLAGS_Debug := \
MY_DEFS_Debug := \
'-DANGLE_DX11' \
- '-DWTF_VECTOR_INITIAL_SIZE=4' \
'-D_FILE_OFFSET_BITS=64' \
'-DNO_TCMALLOC' \
'-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \
@@ -150,7 +149,6 @@ MY_CFLAGS_Release := \
MY_DEFS_Release := \
'-DANGLE_DX11' \
- '-DWTF_VECTOR_INITIAL_SIZE=4' \
'-D_FILE_OFFSET_BITS=64' \
'-DNO_TCMALLOC' \
'-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \
diff --git a/sql/sql.target.darwin-x86.mk b/sql/sql.target.darwin-x86.mk
index 4d162def65..9705192d94 100644
--- a/sql/sql.target.darwin-x86.mk
+++ b/sql/sql.target.darwin-x86.mk
@@ -68,7 +68,6 @@ MY_CFLAGS_Debug := \
MY_DEFS_Debug := \
'-DANGLE_DX11' \
- '-DWTF_VECTOR_INITIAL_SIZE=4' \
'-D_FILE_OFFSET_BITS=64' \
'-DNO_TCMALLOC' \
'-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \
@@ -157,7 +156,6 @@ MY_CFLAGS_Release := \
MY_DEFS_Release := \
'-DANGLE_DX11' \
- '-DWTF_VECTOR_INITIAL_SIZE=4' \
'-D_FILE_OFFSET_BITS=64' \
'-DNO_TCMALLOC' \
'-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \
diff --git a/sql/sql.target.linux-arm.mk b/sql/sql.target.linux-arm.mk
index f837e1af6b..b8fe26c273 100644
--- a/sql/sql.target.linux-arm.mk
+++ b/sql/sql.target.linux-arm.mk
@@ -66,7 +66,6 @@ MY_CFLAGS_Debug := \
MY_DEFS_Debug := \
'-DANGLE_DX11' \
- '-DWTF_VECTOR_INITIAL_SIZE=4' \
'-D_FILE_OFFSET_BITS=64' \
'-DNO_TCMALLOC' \
'-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \
@@ -152,7 +151,6 @@ MY_CFLAGS_Release := \
MY_DEFS_Release := \
'-DANGLE_DX11' \
- '-DWTF_VECTOR_INITIAL_SIZE=4' \
'-D_FILE_OFFSET_BITS=64' \
'-DNO_TCMALLOC' \
'-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \
diff --git a/sql/sql.target.linux-mips.mk b/sql/sql.target.linux-mips.mk
index 6abc4f751c..1cf0ccf0af 100644
--- a/sql/sql.target.linux-mips.mk
+++ b/sql/sql.target.linux-mips.mk
@@ -65,7 +65,6 @@ MY_CFLAGS_Debug := \
MY_DEFS_Debug := \
'-DANGLE_DX11' \
- '-DWTF_VECTOR_INITIAL_SIZE=4' \
'-D_FILE_OFFSET_BITS=64' \
'-DNO_TCMALLOC' \
'-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \
@@ -150,7 +149,6 @@ MY_CFLAGS_Release := \
MY_DEFS_Release := \
'-DANGLE_DX11' \
- '-DWTF_VECTOR_INITIAL_SIZE=4' \
'-D_FILE_OFFSET_BITS=64' \
'-DNO_TCMALLOC' \
'-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \
diff --git a/sql/sql.target.linux-x86.mk b/sql/sql.target.linux-x86.mk
index 4d162def65..9705192d94 100644
--- a/sql/sql.target.linux-x86.mk
+++ b/sql/sql.target.linux-x86.mk
@@ -68,7 +68,6 @@ MY_CFLAGS_Debug := \
MY_DEFS_Debug := \
'-DANGLE_DX11' \
- '-DWTF_VECTOR_INITIAL_SIZE=4' \
'-D_FILE_OFFSET_BITS=64' \
'-DNO_TCMALLOC' \
'-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \
@@ -157,7 +156,6 @@ MY_CFLAGS_Release := \
MY_DEFS_Release := \
'-DANGLE_DX11' \
- '-DWTF_VECTOR_INITIAL_SIZE=4' \
'-D_FILE_OFFSET_BITS=64' \
'-DNO_TCMALLOC' \
'-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \