     }
     
     func updateStatementDidFail() throws {
-        // Reset statementCompletion before didRollback eventually executes
+        // Reset transactionState before didRollback eventually executes
         // other statements.
-        let statementCompletion = self.statementCompletion
-        self.statementCompletion = .Regular
-        
-        switch statementCompletion {
-        case .TransactionErrorRollback(let error):
-            // The transaction has been rollbacked from
-            // TransactionObserverType.transactionWillCommit().
+        let transactionState = self.transactionState
+        self.transactionState = .WaitForTransactionCompletion
+        
+        switch transactionState {
+        case .RollbackFromTransactionObserver(let error):
             didRollback()
             throw error
         default:

    case Rollback
}


/// A transaction observer is notified of all changes and transactions committed
/// or rollbacked on a database.

    private var selectStatementCache: [String: SelectStatement] = [:]
    
    /// See setupTransactionHooks(), updateStatementDidFail(), updateStatementDidExecute()
    private var transactionState: TransactionState = .WaitForTransactionCompletion
    
    /// The transaction observers
    private var transactionObservers = [TransactionObserverType]()
