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_) { |