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>
impl<'db> Transaction<'db>
pub fn read_snapshot(&self) -> Snapshot
Sourcepub fn txn_id(&self) -> u64
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.
Sourcepub fn put(
&mut self,
table: &str,
cells: Vec<(u16, Value)>,
) -> Result<Option<i64>>
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.
pub fn put_returning( &mut self, table: &str, cells: Vec<(u16, Value)>, ) -> Result<PutResult>
Sourcepub fn put_batch(
&mut self,
table: &str,
rows: Vec<Vec<(u16, Value)>>,
) -> Result<Vec<Option<i64>>>
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).
Sourcepub fn delete(&mut self, table: &str, row_id: RowId) -> Result<()>
pub fn delete(&mut self, table: &str, row_id: RowId) -> Result<()>
Stage a delete of row_id on table.
Sourcepub fn put_external_state(&mut self, table: &str, state: Vec<u8>) -> Result<()>
pub fn put_external_state(&mut self, table: &str, state: Vec<u8>) -> Result<()>
Stage opaque external-table module state. The payload is committed under
the same WAL TxnCommit as ordinary table writes.
pub fn delete_many( &mut self, table: &str, row_ids: Vec<RowId>, ) -> Result<Vec<OwnedRow>>
pub fn update_many( &mut self, table: &str, updates: Vec<(RowId, Vec<(u16, Value)>)>, ) -> Result<Vec<OwnedRow>>
pub fn upsert( &mut self, table: &str, insert_cells: Vec<(u16, Value)>, action: UpsertAction, ) -> Result<UpsertResult>
pub fn truncate(&mut self, table: &str) -> Result<()>
Auto Trait Implementations§
impl<'db> !RefUnwindSafe for Transaction<'db>
impl<'db> !Send for Transaction<'db>
impl<'db> !Sync for Transaction<'db>
impl<'db> !UnwindSafe for Transaction<'db>
impl<'db> Freeze for Transaction<'db>
impl<'db> Unpin for Transaction<'db>
impl<'db> UnsafeUnpin for Transaction<'db>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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