-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
44 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
// | ||
// Created by Helge Heß. | ||
// Copyright © 2022 ZeeZide GmbH. | ||
// Copyright © 2022-2024 ZeeZide GmbH. | ||
// | ||
|
||
/** | ||
* The transaction type defines whether a transaction needs write access | ||
* and in non-WAL mode, whether a transaction is exclusive (i.e. forbids | ||
* concurrent reads). | ||
* | ||
* The default is ``deferred``, which keeps the transaction in read mode until | ||
* the first modifying operation is issued (e.g. a delete or insert). | ||
* The default is ``immediate``, which directly acquires the database write | ||
* lock. | ||
* It is preferred over ``deferred``, because transaction upgrades will | ||
* immediately fail w/ `SQLITE_BUSY` if the database lock is in use. | ||
* While an immediate transaction will wait to acquire the lock. | ||
*/ | ||
public enum SQLTransactionType: String { | ||
|
||
/// Start a read transaction on the first SELECT and upgrade to a write | ||
/// transaction on the first modification. | ||
/// Careful: When transactions are upgraded by writes and the database is | ||
/// locked already, a `SQLITE_BUSY` error will be issued immediately | ||
/// (i.e. it won't wait for the lock becoming available). | ||
case deferred = "DEFERRED" | ||
|
||
/// Immediatly start a writable transaction | ||
|
||
/// Immediatly start a writable transaction. This will acquire (and possibly | ||
/// wait) for the database write lock. | ||
case immediate = "IMMEDIATE" | ||
|
||
/// The same like ``immediate`` in WAL mode, but forbids reads in others. | ||
/// The same like ``immediate`` in WAL mode, but protects against concurrent | ||
/// reads in others. | ||
case exclusive = "EXCLUSIVE" | ||
|
||
public static let `default` = SQLTransactionType.deferred | ||
public static let `default` = SQLTransactionType.immediate | ||
} |