1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
// SPDX-License-Identifier: MIT OR Apache-2.0
use crateDbPool;
/// Begin a standard deferred transaction.
///
/// # Errors
///
/// Returns a sqlx error if the transaction cannot be started.
pub async
/// Begin a write-intent transaction.
///
/// `SQLite`: issues `BEGIN IMMEDIATE` to acquire the write lock upfront,
/// preventing `SQLITE_BUSY` errors when another writer is active.
///
/// `PostgreSQL`: issues a standard `BEGIN` (MVCC handles concurrency).
/// Callers that need write-exclusion semantics must use `SELECT ... FOR UPDATE`
/// inside the transaction.
///
/// # Errors
///
/// Returns a sqlx error if the transaction cannot be started.
pub async
/// Begin a read-write transaction on `PostgreSQL`.
///
/// # Errors
///
/// Returns a sqlx error if the transaction cannot be started.
pub async