Commit Graph
201 Commits
Author SHA1 Message Date
Gwendal Roué 7a216d7d34 Fix typos in public documentation 2026-11-01 20:45:05 +01:00
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é fa54b74eba [BREAKING] DatabaseWriter async methods support Task cancellation 2024-09-01 15:35:37 +02:00
Gwendal Roué 1de32c267b [BREAKING] Remove DatabaseFuture and concurrentRead
That's one less DispatchSemaphore. We don't need this method anymore.
2024-08-25 11:07:05 +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é 38bb8d3505 Backport temporary copies from GRDBSnapshotTesting 2023-10-28 18:38:15 +02:00
Gwendal Roué 7cbcbe12f0 Expose path on DatabaseReader 2023-08-31 09:42:13 +02:00
Gwendal Roué e79b4e25db Apply Configuration.journalMode 2023-08-25 09:10:33 +01:00
László Kustra 788887a2b8 Remove selector-based NotificationCenter calls on Linux 2023-06-29 16:23:36 +02:00
Gwendal Roué 7e6f71912c Enhance DatabaseQueue read-only transactions 2023-03-29 13:02:31 +02:00
baegteun 557ad3d3d3 OS X -> macOS in Remake or CHANGELOG.md 2023-01-14 11:43:27 +09:00
Gwendal Roué 0dd17a9a16 Turn ValueObservationScheduler into a protocol 2022-12-29 12:38:06 +01:00
Gwendal Roué 2c5a86479a DocC: Transactions and Savepoints 2022-12-17 10:11:36 +01:00
Gwendal Roué 392e9e447d Shared in-memory databases 2022-11-23 18:32:57 +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é 71880a9b8e Enhance Documentation 2022-11-09 13:20:08 +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é 33a039717c Refer to UIApplication notifications by their names
It looks like FB9801372 was fixed
2022-08-21 21:22:34 +02: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é 458e1e2675 BREAKING: throwing DatabaseQueue() initializer
As a consequence, FTS3.tokenize(_:) is a throwing method as well.
2022-08-21 21:22:33 +02:00
Gwendal Roué 6f0d45eedb BREAKING: throwing DatabaseWriter.barrierWriteWithoutTransaction
It used to be rethrowing, but it was then unable to deal with closed databases.

The async version is modified accordingly: it accepts a Result<Database, Error>, instead of a raw Database.

DatabaseMigrator.asyncMigrate is impacted as well: it accepts a Result<Database, Error>, instead of a (Database, Error?) tuple.
2022-08-21 19:21:57 +02:00
Gwendal Roué 0bfb4de02d Enhance DatabaseQueue automatic memory management
We have async methods, now: no need to use a global dispatch queue.
2022-07-09 13:39:11 +02:00
George Nachman bbe94a9607 Make memory management optional.
Memory management may not be desirable for all
users of GRDB. `DatabasePool.releaseMemory`
creates a barrier which may cause normally fast
readers to block for a long time. If this is not a
desirable tradeoff, the new
`automaticMemoryManagement` flag in
`Configuration` allows you to disable this feature
of GRDB.
2022-07-05 15:27:55 -07:00
Gwendal Roué 6ab3fea8fb Refactor ValueObservation 2022-03-17 18:44:30 +01:00
Gwendal Roué 287ceb8b07 Documentation & cleanup 2022-03-17 18:44:30 +01:00
Gwendal Roué 01f4c04c4d DatabaseReader is Sendable 2021-12-08 18:12:28 +01:00
Gwendal Roué 33d9ca0e97 UIApplication notification names are isolated to @MainActor
I believe this is incorrect: FB9801372 (UIApplication.didReceiveMemoryWarningNotification should not be declared @MainActor)

Meanwhile, just use the string version.

A workaround based on a MainActor-isolated task can't work due to conflict between compiler version and minimum iOS target:

    #if compiler(>=5.5) && canImport(_Concurrency)
    if #available(...) { // Check for availability of concurrency runtime
        Task { @MainActor [weak self] in
            NotificationCenter.default.addObserver(..., name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
        }
    } else {
        // IMPOSSIBLE CASE: No access to Task, no access to notification names
    }
    #else
    NotificationCenter.default.addObserver(..., name: UIApplication.didReceiveMemoryWarningNotification, object: nil)
    #endif
2021-12-08 12:48:19 +01:00
Gwendal Roué 6ec3ebc398 Merge branch 'development' into dev/async 2021-12-06 18:04:35 +01:00
Gwendal Roué bb2ce74125 Add helper method Database.isolated(readOnly:) 2021-12-02 09:45: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é 1f73c20ae2 DatabaseWriter async methods
write, writeWithoutTransaction, barrierWriteWithoutTransaction, erase, vacuum, vacuum(into:)
2021-10-17 13:24:10 +02: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
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é c9c652dddc DatabaseMigrator async migrations 2021-03-20 13:25:43 +01:00
Gwendal Roué aceaaf24d2 Paranoid: Wrap DatabaseQueue.read in a transaction
This guarantees snapshot isolation even in case of external connections
2021-02-20 12:59:27 +01:00