             
             switch db.statementCompletion {
             case .TransactionErrorRollback:
-                // The transactionObserver has rollbacked the transaction.
+                // A transactionObserver has rollbacked the transaction.
                 // Don't lose this information.
                 // Next step: updateStatementDidFail()
                 break
             default:
+                db.statementCompletion = .TransactionRollback
                 // Next step: updateStatementDidExecute()
-                db.statementCompletion = .TransactionRollback
             }
             }, dbPointer)
     }

            let db = unsafeBitCast(dbPointer, Database.self)
            
            // Notify change event
            let event = DatabaseEvent(
                kind: DatabaseEvent.Kind(rawValue: updateKind)!,
                databaseName: String.fromCString(databaseName)!,
                tableName: String.fromCString(tableName)!,
                rowID: rowID)
            db.propagateDatabaseDidChangeWithEvent(event)
            }, dbPointer)
        
        
        sqlite3_commit_hook(sqliteConnection, { dbPointer in
            let db = unsafeBitCast(dbPointer, Database.self)
            do {
                try db.propagateDatabaseWillCommit()
                // Next step: updateStatementDidExecute()
                db.statementCompletion = .TransactionCommit
                return 0
            } catch {
                // Next step: sqlite3_rollback_hook callback
                db.statementCompletion = .TransactionErrorRollback(error)
                return 1
            }
            }, dbPointer)

    }
    
    func updateStatementDidExecute() {
        // Reset statementCompletion before didCommit or didRollback eventually
        // execute other statements.
        let statementCompletion = self.statementCompletion
        self.statementCompletion = .Regular
        
        switch statementCompletion {
        case .TransactionCommit:
            didCommit()
        case .TransactionRollback:
            didRollback()
        default:
            break
        }
    }
    
    private func willCommit() throws {
        for observer in transactionObservers {
            try observer.databaseWillCommit()
        }
    }
    
    private func didChangeWithEvent(event: DatabaseEvent) {
        for observer in transactionObservers {
            observer.databaseDidChangeWithEvent(event)
        }
    }
    
    private func didCommit() {
        for observer in transactionObservers {
            observer.databaseDidCommit(self)
        }
    }
    
    private func didRollback() {
        for observer in transactionObservers {
            observer.databaseDidRollback(self)
        }
    }
