mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
Issue #61: recognize savepoints statements
This commit is contained in:
1 parent
92431f20d7
commit
37c16fbb48
1 file changed
+13
@@ -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
|
||||
|
||||
Reference in new issue
Block a user