Issue #61: recognize savepoints statements

This commit is contained in:
Gwendal Roué committed 2016-05-28 14:44:37 +02:00
1 parent 92431f20d7
commit 37c16fbb48
1 file changed
+13
+13
View File
@@ -1019,6 +1019,7 @@ final class StatementCompilationObserver {
let database: Database
var sourceTables: Set<String> = []
var invalidatesDatabaseSchemaCache = false
var savepointAction: (name: String, action: SavepointActionKind)?
init(_ database: Database) {
self.database = database
@@ -1034,6 +1035,11 @@ final class StatementCompilationObserver {
case SQLITE_READ:
let observer = unsafeBitCast(observerPointer, StatementCompilationObserver.self)
observer.sourceTables.insert(String.fromCString(CString1)!)
case SQLITE_SAVEPOINT:
let observer = unsafeBitCast(observerPointer, StatementCompilationObserver.self)
let name = String.fromCString(CString2)!
let action = SavepointActionKind(rawValue: String.fromCString(CString1)!)!
observer.savepointAction = (name: name, action: action)
default:
break
}
@@ -1048,9 +1054,16 @@ final class StatementCompilationObserver {
func reset() {
sourceTables = []
invalidatesDatabaseSchemaCache = false
savepointAction = nil
}
}
enum SavepointActionKind : String {
case Begin = "BEGIN"
case Release = "RELEASE"
case Rollback = "ROLLBACK"
}
// =========================================================================
// MARK: - Transactions