Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: sql/connection.cc

Issue 18180013: Scoped recovery module for sql/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Oops, add recover_unittest.cc Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sql/connection.h ('k') | sql/recover_unittest.cc » ('j') | sql/recovery.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/connection.cc
diff --git a/sql/connection.cc b/sql/connection.cc
index e99b6bc53dacb8f0ab2569d5d6eb01245446be93..1bc1b9caa8e284dae60763ccef54d0a1a9dea37e 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -175,6 +175,10 @@ bool Connection::OpenInMemory() {
return OpenInternal(":memory:");
}
+bool Connection::OpenTemporary() {
+ return OpenInternal("");
+}
+
void Connection::CloseInternal(bool forced) {
// TODO(shess): Calling "PRAGMA journal_mode = DELETE" at this point
// will delete the -journal file. For ChromiumOS or other more
@@ -361,9 +365,7 @@ bool Connection::RazeAndClose() {
}
// Raze() cannot run in a transaction.
- while (transaction_nesting_) {
- RollbackTransaction();
- }
+ RollbackAllTransactions();
bool result = Raze();
@@ -377,6 +379,21 @@ bool Connection::RazeAndClose() {
return result;
}
+void Connection::CloseAndPoison() {
+ if (!db_) {
+ DLOG_IF(FATAL, !poisoned_) << "Cannot poison null db";
erikwright (departed) 2013/07/05 19:02:30 is this different from DCHECK(poisoned) << "..";?
Scott Hess - ex-Googler 2013/07/08 21:41:51 Once Upon A Time, in a refactor we had a big knock
+ return;
+ }
+
+ RollbackAllTransactions();
+ CloseInternal(true);
+
+ // Mark the database so that future API calls fail appropriately,
+ // but don't DCHECK (because after calling this function they are
+ // expected to fail).
+ poisoned_ = true;
+}
+
// TODO(shess): To the extent possible, figure out the optimal
// ordering for these deletes which will prevent other connections
// from seeing odd behavior. For instance, it may be necessary to
@@ -462,6 +479,13 @@ bool Connection::CommitTransaction() {
return commit.Run();
}
+void Connection::RollbackAllTransactions() {
+ if (transaction_nesting_ > 0) {
+ transaction_nesting_ = 0;
+ DoRollback();
+ }
+}
+
int Connection::ExecuteAndReturnErrorCode(const char* sql) {
AssertIOAllowed();
if (!db_) {
« no previous file with comments | « sql/connection.h ('k') | sql/recover_unittest.cc » ('j') | sql/recovery.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698