Skip to main content

Transaction

Struct Transaction 

Source
pub struct Transaction<'db> { /* private fields */ }
Expand description

An in-flight cross-table transaction. Holds a read snapshot taken at begin and stages writes; nothing is durable or visible until Self::commit.

Implementations§

Source§

impl<'db> Transaction<'db>

Source

pub fn read_snapshot(&self) -> Snapshot

Source

pub fn txn_id(&self) -> u64

The transaction’s id (generation-scoped: high 32 bits = open generation, low 32 = per-open counter). Mainly diagnostic / test-facing.

Source

pub fn put( &mut self, table: &str, cells: Vec<(u16, Value)>, ) -> Result<Option<i64>>

Stage a put on table. The row id is allocated at commit so an aborted transaction never consumes ids. If the table has an AUTO_INCREMENT primary key and the column is omitted or null, the engine fills it now and returns the assigned value; explicit ids are honored and advance the counter. The value is staged in cells, so the commit path writes the same id into the row.

Source

pub fn put_returning( &mut self, table: &str, cells: Vec<(u16, Value)>, ) -> Result<PutResult>

Source

pub fn put_batch( &mut self, table: &str, rows: Vec<Vec<(u16, Value)>>, ) -> Result<Vec<Option<i64>>>

Stage many puts on the same table with one table-id lookup + one auto-inc lock pass. Each row is staged individually (same as repeated put); the savings are the amortized lookups/locks for bulk guard-row writes and batched application-row inserts. Returns the assigned auto-increment values (Some only where the engine filled the column).

Source

pub fn delete(&mut self, table: &str, row_id: RowId) -> Result<()>

Stage a delete of row_id on table.

Source

pub fn delete_many( &mut self, table: &str, row_ids: Vec<RowId>, ) -> Result<Vec<OwnedRow>>

Source

pub fn update_many( &mut self, table: &str, updates: Vec<(RowId, Vec<(u16, Value)>)>, ) -> Result<Vec<OwnedRow>>

Source

pub fn upsert( &mut self, table: &str, insert_cells: Vec<(u16, Value)>, action: UpsertAction, ) -> Result<UpsertResult>

Source

pub fn truncate(&mut self, table: &str) -> Result<()>

Source

pub fn commit(self) -> Result<Epoch>

Commit: durably seal the staging under one epoch and publish it.

Source

pub fn rollback(self)

Rollback: discard staging. Nothing is appended to the WAL.

Auto Trait Implementations§

§

impl<'db> !RefUnwindSafe for Transaction<'db>

§

impl<'db> !UnwindSafe for Transaction<'db>

§

impl<'db> Freeze for Transaction<'db>

§

impl<'db> Send for Transaction<'db>

§

impl<'db> Sync for Transaction<'db>

§

impl<'db> Unpin for Transaction<'db>

§

impl<'db> UnsafeUnpin for Transaction<'db>

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.