pub struct TransactionController { /* private fields */ }Expand description
Manages the transaction lifecycle for a single connection.
Tracks the current transaction mode, lock level, and savepoint stack.
This is the “SQL layer” state machine; the underlying MVCC machinery
lives in fsqlite_mvcc::lifecycle::TransactionManager.
Implementations§
Source§impl TransactionController
impl TransactionController
Sourcepub const fn lock_level(&self) -> LockLevel
pub const fn lock_level(&self) -> LockLevel
Current lock level.
Sourcepub const fn mode(&self) -> Option<TransactionMode>
pub const fn mode(&self) -> Option<TransactionMode>
Current transaction mode.
Sourcepub const fn is_concurrent(&self) -> bool
pub const fn is_concurrent(&self) -> bool
Whether we are in CONCURRENT (MVCC) mode.
Sourcepub fn savepoint_depth(&self) -> usize
pub fn savepoint_depth(&self) -> usize
Number of savepoints on the stack.
Sourcepub fn begin(&mut self, mode: Option<TransactionMode>) -> Result<()>
pub fn begin(&mut self, mode: Option<TransactionMode>) -> Result<()>
Begin a transaction with the given mode.
§Errors
Returns FrankenError::Busy if a transaction is already active.
Sourcepub fn commit(&mut self) -> Result<()>
pub fn commit(&mut self) -> Result<()>
Commit the active transaction.
END TRANSACTION is a synonym for COMMIT (invariant #5).
§Errors
Returns error if no transaction is active or if in error state.
Sourcepub fn rollback(&mut self) -> Result<()>
pub fn rollback(&mut self) -> Result<()>
Roll back the active transaction, undoing all changes since BEGIN.
§Errors
Returns error if no transaction is active.
Sourcepub fn savepoint(&mut self, name: String) -> Result<()>
pub fn savepoint(&mut self, name: String) -> Result<()>
Create a named savepoint (pushes onto LIFO stack).
If no transaction is active, implicitly starts a DEFERRED transaction (per SQLite semantics: SAVEPOINT outside a transaction starts one).
Sourcepub fn release(&mut self, name: &str) -> Result<()>
pub fn release(&mut self, name: &str) -> Result<()>
RELEASE savepoint: commits all work since SAVEPOINT X and removes X and all more recent savepoints from the stack (invariant #6).
§Errors
Returns error if the named savepoint is not on the stack.
Sourcepub fn rollback_to(&mut self, name: &str) -> Result<()>
pub fn rollback_to(&mut self, name: &str) -> Result<()>
ROLLBACK TO savepoint: undoes all work since SAVEPOINT X but leaves X on the stack for further use (invariant #7).
§Errors
Returns error if the named savepoint is not on the stack.
Sourcepub fn record_write(&mut self, page_number: u64, data: Vec<u8>)
pub fn record_write(&mut self, page_number: u64, data: Vec<u8>)
Record a page write in the write set (for savepoint rollback support).
Sourcepub fn promote_on_read(&mut self)
pub fn promote_on_read(&mut self)
Promote lock level on first read (DEFERRED → SHARED) or first write (SHARED/RESERVED → appropriate level).
Sourcepub fn promote_on_write(&mut self)
pub fn promote_on_write(&mut self)
Promote lock level on first write.