SqlTransaction

Struct SqlTransaction 

Source
pub struct SqlTransaction<'a, S: KVStore + 'a> { /* private fields */ }
Expand description

SQL transaction wrapping a KV transaction.

Provides SQL-friendly access to table and index storage, with explicit commit/rollback control.

Implementations§

Source§

impl<'a, S: KVStore + 'a> SqlTransaction<'a, S>

Source

pub fn mode(&self) -> TxnMode

Returns the transaction mode.

Source

pub fn table_storage<'b>( &'b mut self, table_meta: &TableMetadata, ) -> TableStorage<'b, 'a, S::Transaction<'a>>

Get a table storage handle.

Returns a TableStorage instance that borrows this transaction. The returned storage is valid for the duration of the borrow.

The table_id is obtained from table_meta.table_id.

Source

pub fn index_storage<'b>( &'b mut self, index_id: u32, unique: bool, column_indices: Vec<usize>, ) -> IndexStorage<'b, 'a, S::Transaction<'a>>

Get an index storage handle.

Returns an IndexStorage instance that borrows this transaction. The returned storage is valid for the duration of the borrow.

Source

pub fn delete_prefix(&mut self, prefix: &[u8]) -> Result<()>

Delete all keys with the given prefix.

Source

pub fn with_table<R, F>( &mut self, table_meta: &TableMetadata, f: F, ) -> Result<R>
where F: FnOnce(&mut TableStorage<'_, 'a, S::Transaction<'a>>) -> Result<R>,

Execute operations on a table within a closure.

This is a convenience method that creates a TableStorage, executes the closure, and returns the result.

The table_id is obtained from table_meta.table_id.

Source

pub fn with_index<R, F>( &mut self, index_id: u32, unique: bool, column_indices: Vec<usize>, f: F, ) -> Result<R>
where F: FnOnce(&mut IndexStorage<'_, 'a, S::Transaction<'a>>) -> Result<R>,

Execute operations on an index within a closure.

This is a convenience method that creates an IndexStorage, executes the closure, and returns the result.

Source

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

Commit the transaction.

Consumes the transaction. On success, all writes become visible.

Source

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

Rollback the transaction.

Consumes the transaction. All pending writes are discarded.

Trait Implementations§

Source§

impl<'a, S: KVStore + 'a> SqlTxn<'a, S> for SqlTransaction<'a, S>

Source§

fn mode(&self) -> TxnMode

Source§

fn ensure_write_txn(&self) -> CoreResult<()>

Source§

fn inner_mut(&mut self) -> &mut S::Transaction<'a>

Source§

fn hnsw_entry(&mut self, name: &str) -> CoreResult<&HnswIndex>

Source§

fn hnsw_entry_mut(&mut self, name: &str) -> CoreResult<&mut HnswTxnEntry>

Source§

fn flush_hnsw(&mut self) -> Result<()>

Source§

fn abandon_hnsw(&mut self) -> Result<()>

Source§

fn delete_prefix(&mut self, prefix: &[u8]) -> Result<()>

Source§

fn table_storage<'a>( &'a mut self, table_meta: &TableMetadata, ) -> TableStorage<'a, 'txn, S::Transaction<'txn>>

Source§

fn index_storage<'a>( &'a mut self, index_id: u32, unique: bool, column_indices: Vec<usize>, ) -> IndexStorage<'a, 'txn, S::Transaction<'txn>>

Source§

fn with_table<R, F>(&mut self, table_meta: &TableMetadata, f: F) -> Result<R>
where F: FnOnce(&mut TableStorage<'_, 'txn, S::Transaction<'txn>>) -> Result<R>,

Source§

fn with_index<R, F>( &mut self, index_id: u32, unique: bool, column_indices: Vec<usize>, f: F, ) -> Result<R>
where F: FnOnce(&mut IndexStorage<'_, 'txn, S::Transaction<'txn>>) -> Result<R>,

Auto Trait Implementations§

§

impl<'a, S> Freeze for SqlTransaction<'a, S>
where <S as KVStore>::Transaction<'a>: Freeze,

§

impl<'a, S> !RefUnwindSafe for SqlTransaction<'a, S>

§

impl<'a, S> Send for SqlTransaction<'a, S>
where <S as KVStore>::Transaction<'a>: Send,

§

impl<'a, S> Sync for SqlTransaction<'a, S>
where <S as KVStore>::Transaction<'a>: Sync,

§

impl<'a, S> Unpin for SqlTransaction<'a, S>
where <S as KVStore>::Transaction<'a>: Unpin,

§

impl<'a, S> !UnwindSafe for SqlTransaction<'a, S>

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, 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, 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