Commit Graph
99 Commits
Author SHA1 Message Date
Gwendal Roué 4cfa692ddd Fix race condition regarding Task cancellation
This complements #1797 by making sure read-only transactions complete correctly, even if the task is cancelled.
2025-09-10 07:12:11 +02:00
Gwendal Roué d242421862 Async methods accept a non-escaping closure 2025-07-19 16:42:17 +02:00
Gwendal Roué cbbd0cb945 Add asserts about expected ends of transaction 2025-07-19 14:25:50 +02:00
Gwendal Roué 46e15616a7 [BREAKING] macOS 10.15+ 2024-09-21 14:28:24 +02:00
Gwendal Roué e4a4735494 [BREAKING] tvOS 13+ 2024-09-21 13:57:35 +02:00
Gwendal Roué 8c40592955 [BREAKING] iOS 13+ 2024-09-21 13:57:23 +02:00
Gwendal Roué 2f240fd764 [SENDING REGRET] Async database access methods return Sendable results
We can not tell the compiler that we can safely return `sending` results, because fetched values are in the same region as the `db` argument, according to SE-0414 (https://github.com/swiftlang/swift-evolution/blob/main/proposals/0414-region-based-isolation.md#rules-for-merging-isolation-regions).

```
class NotSendable { init() { } }
func fetchNotSendable(_ db: Database) -> NotSendable { fatalError() }

func notOK<T>(_ make: (Database) -> sending T) { }
func ok<T>(_ make: () -> sending T) { }

func usage() {
    ok { NotSendable() }

    // Returning a task-isolated 'NotSendable' value as a 'sending' result
    // risks causing data races.
    notOK { db in fetchNotSendable(db) }
}
```

Various attempts at modifying all fetching methods so that they have a `sending` return value have failed.
2024-09-08 16:55:25 +02:00
Gwendal Roué 5f384a4b22 ValueObservation is Sendable 2024-09-08 16:17:51 +02:00
Gwendal Roué 62d96ec544 [SENDING REGRET] Async database accesses require Sendable closures
We should be able to use sending closures instead, but DispatchQueue.async does not accept sending closures yet.
2024-09-08 16:16:40 +02:00
Gwendal Roué a7a9c75185 Place @escaping before @Sendable 2024-09-08 13:41:13 +02:00
Gwendal Roué d6b91eec85 [BREAKING] DatabaseReader async methods support Task cancellation 2024-09-01 15:35:37 +02:00
Gwendal Roué 451a9eb493 [BREAKING] Remove Configuration.defaultTransactionKind
GRDB now defaults read-only transactions to DEFERRED, and write transactions to IMMEDIATE. See https://github.com/groue/GRDB.swift/issues/1483 for some context.
2024-08-25 08:22:07 +02:00
Gwendal Roué 8fa434272e Make all read closures explicit in the documentation
The short form dbQueue.read(fetch) can confuse the reader.
2023-10-22 07:59:08 +02:00
Gwendal Roué 0dd17a9a16 Turn ValueObservationScheduler into a protocol 2022-12-29 12:38:06 +01:00
Gwendal Roué 10596e17bf Cleanup snapshot configurations 2022-11-23 19:42:12 +01:00
Gwendal Roué b1770e89b7 Introduce DatabaseSnapshotReader 2022-11-17 20:11:58 +01:00
Gwendal Roué 12d656d3a1 Let SQLite check if DatabaseSnapshotPool can be created 2022-11-17 20:01:17 +01:00
Gwendal Roué 0bc49460d7 DatabaseSnapshotPool uses its own pool of connections
In the previous implementation, the snapshot pool would use the same reader connections as the database pool. This would create problem with reentrant reads. Let's make things simple, and not share any database connection.
2022-11-17 18:36:17 +01:00
Gwendal Roué b8bc8273a9 Turn snapshot tokens into a proper reader: DatabaseSnapshotPool 2022-11-14 18:22:13 +01:00
Gwendal Roué a71eb3d662 Introduce WALSnapshotToken 2022-11-13 18:28:54 +01:00
Gwendal Roué 997d6cb677 DatabaseSnapshot does not require the WAL mode
One can create a snapshot from a read-only pool on a non-WAL database, and that's OK. The snaphost still sees an unchanging database content (but other connections can't write).
2022-11-13 10:54:40 +01:00
Gwendal Roué 51230834c8 Configuration.maximumReaderCount can be queried
This is useful for tools that adapt their own inner scheduling to the actual capacity for concurrent reads.
2022-11-13 10:54:40 +01:00
Gwendal Roué 85b2e113b2 Relocate DatabaseSnapshot documentation 2022-11-09 17:16:03 +01:00
Gwendal Roué 13c804d1cc DocC 2022-11-06 16:02:36 +01:00
Gwendal Roué 1818534513 DocC 2022-11-06 16:02:36 +01:00
Gwendal Roué a9fcf1b9c1 SE-0335, SE-0341, SE-0346, SE-0352, SE-0358: some, any, primary associated types 2022-08-21 21:22:34 +02:00
Gwendal Roué 38c0d68db7 WALSnapshot
SQLITE_ENABLE_SNAPSHOT is available from Xcode 14 :-)
2022-06-24 16:48:38 +02:00
Gwendal Roué 6ab3fea8fb Refactor ValueObservation 2022-03-17 18:44:30 +01:00
Gwendal Roué 1b62e06c4a Expose Sendable conformance to Swift 5.5
But async apis are still only exposed to Swift 5.5.2.

Sendable conformances are helpful for users of Xcode < 13.2.
2021-12-10 08:08:47 +01:00
Gwendal Roué 01f4c04c4d DatabaseReader is Sendable 2021-12-08 18:12:28 +01:00
Gwendal Roué 1a87faacfa Merge branch 'development' into dev/async 2021-10-31 18:32:03 +01:00
Gwendal Roué 20cb50f52d Public close() method 2021-10-31 18:12:13 +01:00
Gwendal Roué a827188881 async DatabaseReader.unsafeRead 2021-10-17 13:23:34 +02:00
Gwendal Roué ba88a150c0 Improve inline doc of database access methods 2021-10-11 15:50:06 +02:00
Gwendal Roué bf601e6810 Merge SelectStatement and UpdateStatement
Addresses #1015
2021-07-29 20:20:15 +02:00
Zev Eisenberg 8b060e6b09 Add angle brackets to URLs to make them clickable in Xcode's rendered documentation. 2021-07-20 20:53:58 -04:00
Gwendal Roué b13922b76e Database schema cache distinguishes the main from the temp schema
Addresses https://github.com/groue/GRDB.swift/pull/946#issuecomment-805756799
2021-03-27 14:50:25 +01:00
Gwendal Roué 836efb120f Xcode 12.3 formatting 2020-12-23 12:13:05 +01:00
Gwendal Roué f84e25f929 Remove dependency on SQLITE_ENABLE_SNAPSHOT
Address #845 and #846
2020-10-06 08:30:41 +02:00
Gwendal Roué 7a2c1413fe Fix DatabaseSnapshot 2020-09-06 13:40:03 +02:00
Gwendal Roué 3c38aa1996 Functions, Collations, and tokenizers are no longer available on DatabaseQueue, Pool, and Snapshot 2020-09-06 13:18:58 +02:00
Gwendal Roué 86b9616dd7 DatabasePool readers don't invalidate their database schema cache until schema is actually changed. 2020-07-25 18:20:43 +02:00
Gwendal Roué 07092169bf Documentation 2020-07-12 14:17:58 +02:00
Gwendal Roué 813950f832 Avoid SQLITE_BUSY when opening a DatabaseSnapshot. 2020-07-09 17:45:57 +02:00
Gwendal Roué 5c4b282e27 Refactor ValueObservation events handling 2020-06-21 09:17:12 +02:00
Gwendal Roué dd76cdffec ValueObservation.handleEvents 2020-06-20 19:57:51 +02:00
Gwendal Roué 70714768d9 Always use snapshots apis through grdb_xxx shims 2020-06-14 15:38:16 +02:00
Gwendal Roué 9215f88e7f Documentation, cleanup, and checkpoint prevention 2020-06-14 10:47:27 +02:00
Gwendal Roué 27120643b9 SE-0255: Implicit returns from single-expression functions 2020-04-09 17:16:23 +02:00
Gwendal Roué d72000c6a3 Use scheduling paramater name for consistency with GRDBCombine and RxGRDB 2020-03-31 20:25:36 +02:00