Cache frequently used statements

This commit is contained in:
Gwendal Roué committed 2018-11-18 16:49:14 +01:00
1 parent 7e548aee13
commit 65cc0bb2b3
3 files changed
+5 -5

No files matched your search

+2 -2
View File
@@ -549,8 +549,8 @@ extension Database {
// query_only pragma was added in SQLite 3.8.0 http://www.sqlite.org/changes.html#version_3_8_0
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
// Assume those pragmas never fail
try! execute("PRAGMA query_only = 1")
defer { try! execute("PRAGMA query_only = 0") }
try! internalCachedUpdateStatement("PRAGMA query_only = 1").execute()
defer { try! internalCachedUpdateStatement("PRAGMA query_only = 0").execute() }
return try block()
}
}
+2 -2
View File
@@ -451,7 +451,7 @@ extension DatabasePool : DatabaseReader {
do {
try db.beginTransaction(.deferred)
assert(db.isInsideTransaction)
try db.makeSelectStatement("SELECT rootpage FROM sqlite_master").makeCursor().next()
try db.internalCachedSelectStatement("SELECT rootpage FROM sqlite_master").makeCursor().next()
} catch {
readError = error
semaphore.signal() // Release the writer queue and rethrow error
@@ -545,7 +545,7 @@ extension DatabasePool : DatabaseReader {
defer { _ = try? db.commit() }
do {
try db.beginTransaction(.deferred)
try db.makeSelectStatement("SELECT rootpage FROM sqlite_master").makeCursor().next()
try db.internalCachedSelectStatement("SELECT rootpage FROM sqlite_master").makeCursor().next()
} catch {
// Snapshot isolation failure
futureResult = .failure(error)
+1 -1
View File
@@ -37,7 +37,7 @@ public class DatabaseSnapshot : DatabaseReader {
// Take snapshot
// See DatabasePool.concurrentRead for a complete discussion
try db.makeSelectStatement("SELECT rootpage FROM sqlite_master").makeCursor().next()
try db.internalCachedSelectStatement("SELECT rootpage FROM sqlite_master").makeCursor().next()
}
}