Sqlite: WAL frame admission and automatic rollback reporting (#47)

This commit is contained in:
faumaray committed 2026-12-03 15:48:31 +03:00
1 parent b3c566ed4d
commit a40882522a
5 files changed
+364 -28

No files matched your search

+12 -8
View File
@@ -181,7 +181,8 @@ namespace Void::Sqlite
};
/// RAII transaction retaining shared ConnectionState. Never marks Committed
/// before COMMIT succeeds; inspects sqlite3_get_autocommit on error.
/// before COMMIT succeeds; inspects sqlite3_get_autocommit on error and after
/// statements so an automatic rollback is reported as RolledBack.
class Transaction
{
public:
@@ -192,11 +193,11 @@ namespace Void::Sqlite
Transaction(const Transaction&) = delete;
Transaction& operator=(const Transaction&) = delete;
[[nodiscard]] TransactionState state() const noexcept { return m_state; }
[[nodiscard]] bool is_active() const noexcept
{
return m_state == TransactionState::Active;
}
/// Observes the native autocommit state; returns RolledBack when SQLite
/// already ended this transaction (for example SQLITE_FULL or an
/// interrupt inside the transaction).
[[nodiscard]] TransactionState state() const noexcept;
[[nodiscard]] bool is_active() const noexcept;
Result<void> commit();
[[nodiscard]] Result<void> rollback_checked();
@@ -204,10 +205,13 @@ namespace Void::Sqlite
private:
friend class Database;
explicit Transaction(std::shared_ptr<detail::ConnectionState> conn) noexcept;
explicit Transaction(std::shared_ptr<detail::ConnectionState> conn,
std::uint64_t id) noexcept;
void refresh_state() const noexcept;
std::shared_ptr<detail::ConnectionState> m_conn{};
TransactionState m_state{TransactionState::RolledBack};
std::uint64_t m_id{0};
mutable TransactionState m_state{TransactionState::RolledBack};
};
/// Separately owned nested savepoint scope.