pub struct TransactionState {
pub id: u64,
pub active: bool,
/* private fields */
}Expand description
Transaction state for a session.
Tracks uncommitted changes during an active transaction, providing READ COMMITTED isolation when multiple sessions share a database.
Fields§
§id: u64Transaction ID (monotonically increasing)
active: boolWhether we’re in an active transaction block
Implementations§
Source§impl TransactionState
impl TransactionState
Sourcepub fn record_insert(&mut self, table_name: String, row: Row)
pub fn record_insert(&mut self, table_name: String, row: Row)
Record an insert operation.
Sourcepub fn record_update(
&mut self,
table_name: String,
row_index: usize,
old_row: Row,
new_row: Row,
)
pub fn record_update( &mut self, table_name: String, row_index: usize, old_row: Row, new_row: Row, )
Record an update operation.
Sourcepub fn record_delete(&mut self, table_name: String, row_index: usize, row: Row)
pub fn record_delete(&mut self, table_name: String, row_index: usize, row: Row)
Record a delete operation.
Sourcepub fn record_create_table(&mut self, table_name: String)
pub fn record_create_table(&mut self, table_name: String)
Record a table creation.
Sourcepub fn record_drop_table(&mut self, table_name: String)
pub fn record_drop_table(&mut self, table_name: String)
Record a table drop.
Sourcepub fn record_create_index(&mut self, index_name: String, table_name: String)
pub fn record_create_index(&mut self, index_name: String, table_name: String)
Record an index creation.
Sourcepub fn record_drop_index(&mut self, index_name: String)
pub fn record_drop_index(&mut self, index_name: String)
Record an index drop.
Sourcepub fn get_inserted_rows(&self, table_name: &str) -> Option<&Vec<Row>>
pub fn get_inserted_rows(&self, table_name: &str) -> Option<&Vec<Row>>
Get rows inserted in this transaction for a table.
Sourcepub fn get_deleted_indices(&self, table_name: &str) -> Option<&Vec<usize>>
pub fn get_deleted_indices(&self, table_name: &str) -> Option<&Vec<usize>>
Get indices of rows deleted in this transaction for a table.
Sourcepub fn get_updated_rows(&self, table_name: &str) -> Option<&HashMap<usize, Row>>
pub fn get_updated_rows(&self, table_name: &str) -> Option<&HashMap<usize, Row>>
Get updated rows for a table (index -> new_row).
Sourcepub fn is_deleted(&self, table_name: &str, row_index: usize) -> bool
pub fn is_deleted(&self, table_name: &str, row_index: usize) -> bool
Check if a row at a given index was deleted in this transaction.
Sourcepub fn get_updated_row(
&self,
table_name: &str,
row_index: usize,
) -> Option<&Row>
pub fn get_updated_row( &self, table_name: &str, row_index: usize, ) -> Option<&Row>
Get the updated version of a row if it was updated in this transaction.
Sourcepub fn take_changes(self) -> Vec<TransactionChange>
pub fn take_changes(self) -> Vec<TransactionChange>
Consume the transaction state and return all changes for commit.
Sourcepub fn changes(&self) -> &[TransactionChange]
pub fn changes(&self) -> &[TransactionChange]
Get all changes (for inspection without consuming).
Sourcepub fn has_changes(&self) -> bool
pub fn has_changes(&self) -> bool
Check if there are any uncommitted changes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TransactionState
impl RefUnwindSafe for TransactionState
impl Send for TransactionState
impl Sync for TransactionState
impl Unpin for TransactionState
impl UnsafeUnpin for TransactionState
impl UnwindSafe for TransactionState
Blanket Implementations§
impl<T> Allocation for T
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request