         try execute("COMMIT TRANSACTION")
     }
     
+    public func addTransactionObserver(transactionObserver: TransactionObserverType) {
+        preconditionValidQueue()
+        transactionObservers.append(transactionObserver)
+    }
+    
+    public func removeTransactionObserver(transactionObserver: TransactionObserverType) {
+        preconditionValidQueue()
+        if let index = transactionObservers.indexOf({ observer in observer === transactionObserver}) {
+            transactionObservers.removeAtIndex(index)
+        }
+    }
+    
     func updateStatementDidFail() throws {
+        // Reset statementCompletion before didRollback eventually executes
+        // other statements.
         let statementCompletion = self.statementCompletion
         self.statementCompletion = .Regular
         

    }
    
    func updateStatementDidExecute() {
        let statementCompletion = self.statementCompletion
        self.statementCompletion = .Regular
        
        switch statementCompletion {
        case .TransactionCommit:
            propagateDatabaseDidCommit()
        case .TransactionRollback:
            propagateDatabaseDidRollback()
        default:
            break
        }
    }
    
    private func propagateDatabaseWillCommit() throws {
        for observer: TransactionObserverType in transactionObservers {
            try observer.databaseWillCommit()
        }
    }
    
    private func propagateDatabaseDidChangeWithEvent(event: DatabaseEvent) {
        for observer: TransactionObserverType in transactionObservers {
            observer.databaseDidChangeWithEvent(event)
        }
    }
    
    private func propagateDatabaseDidCommit() {
        for observer: TransactionObserverType in transactionObservers {
            observer.databaseDidCommit(self)
        }
    }
    
    private func propagateDatabaseDidRollback() {
        for observer: TransactionObserverType in transactionObservers {
            observer.databaseDidRollback(self)
        }
    }

        case .TransactionErrorRollback(let error):
            // The transaction has been rollbacked from
            // TransactionObserverType.transactionWillCommit().
            didRollback()
            throw error
        default:
            break
