Merge vl-sqlite-02: unknown commit outcome after WAL I/O error (VL-SQLITE-02)
This commit is contained in:
commit
103523f04a
4 files changed
+165
-11
No files matched your search
@@ -182,7 +182,9 @@ namespace Void::Sqlite
|
||||
|
||||
/// RAII transaction retaining shared ConnectionState. Never marks Committed
|
||||
/// before COMMIT succeeds; inspects sqlite3_get_autocommit on error and after
|
||||
/// statements so an automatic rollback is reported as RolledBack.
|
||||
/// statements so an automatic rollback is reported as RolledBack. A failed
|
||||
/// COMMIT whose outcome cannot be proven (WAL I/O error) is reported as
|
||||
/// Unknown, never as RolledBack.
|
||||
class Transaction
|
||||
{
|
||||
public:
|
||||
@@ -199,6 +201,10 @@ namespace Void::Sqlite
|
||||
[[nodiscard]] TransactionState state() const noexcept;
|
||||
[[nodiscard]] bool is_active() const noexcept;
|
||||
|
||||
/// Commits the transaction. On failure state() is Active (SQLite kept
|
||||
/// the transaction open; retry or roll back), RolledBack (SQLite ended
|
||||
/// it and it was not committed), or Unknown (SQLite ended it but a WAL
|
||||
/// I/O error means the commit may have taken effect).
|
||||
Result<void> commit();
|
||||
[[nodiscard]] Result<void> rollback_checked();
|
||||
void rollback() noexcept;
|
||||
|
||||
@@ -50,10 +50,22 @@ namespace Void::Sqlite
|
||||
};
|
||||
|
||||
enum class TransactionState : std::uint8_t {
|
||||
/// The transaction is open; statements execute inside it.
|
||||
Active,
|
||||
/// COMMIT succeeded and the transaction is durable.
|
||||
Committed,
|
||||
/// SQLite ended the transaction without committing it (explicit or
|
||||
/// automatic rollback, or the transaction never started).
|
||||
RolledBack,
|
||||
RecoveryRequired
|
||||
/// The connection or rollback state is unusable; the application must
|
||||
/// recover before continuing.
|
||||
RecoveryRequired,
|
||||
/// COMMIT failed and SQLite ended the transaction, but the wrapper cannot
|
||||
/// prove whether the commit took effect. A WAL I/O error can be reported
|
||||
/// after the commit record became durable, so this must never be treated
|
||||
/// as a definite rollback: inspect the database before assuming either
|
||||
/// outcome.
|
||||
Unknown
|
||||
};
|
||||
|
||||
enum class ColumnType : std::uint8_t {
|
||||
@@ -453,6 +465,10 @@ namespace Void::Sqlite
|
||||
/// If true along with fail_next_commit_rc, simulates SQLite
|
||||
/// auto-rollback before returning the error.
|
||||
bool auto_rollback_on_faulted_commit{false};
|
||||
/// If true along with fail_next_commit_rc, the COMMIT is executed and
|
||||
/// committed first, and the error is reported afterwards. Models a lost
|
||||
/// commit acknowledgement, where the outcome is genuinely unknown.
|
||||
bool commit_applied_before_error{false};
|
||||
/// If non-zero, next explicit close() returns this SQLite error code.
|
||||
int fail_next_close_rc{0};
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user