Skip to main content

TransactionController

Struct TransactionController 

Source
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

Source

pub fn new() -> Self

Create a new transaction controller in idle state.

Source

pub const fn state(&self) -> TxnState

Current transaction state.

Source

pub const fn lock_level(&self) -> LockLevel

Current lock level.

Source

pub const fn mode(&self) -> Option<TransactionMode>

Current transaction mode.

Source

pub const fn is_concurrent(&self) -> bool

Whether we are in CONCURRENT (MVCC) mode.

Source

pub fn savepoint_depth(&self) -> usize

Number of savepoints on the stack.

Source

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.

Source

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.

Source

pub fn rollback(&mut self) -> Result<()>

Roll back the active transaction, undoing all changes since BEGIN.

§Errors

Returns error if no transaction is active.

Source

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).

Source

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.

Source

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.

Source

pub fn record_write(&mut self, page_number: u64, data: Vec<u8>)

Record a page write in the write set (for savepoint rollback support).

Source

pub fn promote_on_read(&mut self)

Promote lock level on first read (DEFERRED → SHARED) or first write (SHARED/RESERVED → appropriate level).

Source

pub fn promote_on_write(&mut self)

Promote lock level on first write.

Source

pub fn set_error(&mut self)

Mark transaction as in error state (e.g., after a constraint violation).

Trait Implementations§

Source§

impl Debug for TransactionController

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TransactionController

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more