mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Database.checkpoint
This commit is contained in:
1 parent
fc57a69672
commit
b3e1bf6f05
2 files changed
+10
-8
No files matched your search
@@ -629,7 +629,15 @@ extension Database {
|
||||
}
|
||||
|
||||
extension Database {
|
||||
|
||||
func checkpoint(_ kind: Database.CheckpointMode) throws {
|
||||
let code = sqlite3_wal_checkpoint_v2(sqliteConnection, nil, kind.rawValue, nil, nil)
|
||||
guard code == SQLITE_OK else {
|
||||
throw DatabaseError(resultCode: code, message: lastErrorMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Database {
|
||||
// MARK: - Transactions & Savepoint
|
||||
|
||||
/// Executes a block inside a database transaction.
|
||||
|
||||
@@ -154,13 +154,7 @@ extension DatabasePool {
|
||||
/// - parameter kind: The checkpoint mode (default passive)
|
||||
public func checkpoint(_ kind: Database.CheckpointMode = .passive) throws {
|
||||
try writer.sync { db in
|
||||
// TODO: read https://www.sqlite.org/c3ref/wal_checkpoint_v2.html and
|
||||
// check whether we need a busy handler on writer and/or readers
|
||||
// when kind is not .Passive.
|
||||
let code = sqlite3_wal_checkpoint_v2(db.sqliteConnection, nil, kind.rawValue, nil, nil)
|
||||
guard code == SQLITE_OK else {
|
||||
throw DatabaseError(resultCode: code, message: db.lastErrorMessage)
|
||||
}
|
||||
try db.checkpoint(kind)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user