pub struct WriteTxn { /* private fields */ }Expand description
An open write transaction on the single writer connection. Run ordinary SQL with
exec/exec_batch; the preupdate hook
captures row deltas. commit derives against a read-only
pre-commit snapshot and batch overlay, commits SQL, then calls subscribers.
Dropping without committing rolls back and delivers no events.
Implementations§
Source§impl WriteTxn
impl WriteTxn
Sourcepub fn exec(
&mut self,
sql: &str,
params: &[OwnedValue],
) -> Result<usize, ReplicaError>
pub fn exec( &mut self, sql: &str, params: &[OwnedValue], ) -> Result<usize, ReplicaError>
Run one statement with positional parameters inside the open transaction. Returns the number of rows changed. The preupdate hook captures the row deltas.
Sourcepub fn exec_batch(&mut self, sql: &str) -> Result<(), ReplicaError>
pub fn exec_batch(&mut self, sql: &str) -> Result<(), ReplicaError>
Run a batch of statements (no parameters) inside the open transaction.
Sourcepub fn commit(self) -> Result<TxId, ReplicaError>
pub fn commit(self) -> Result<TxId, ReplicaError>
Commit: derive each query’s incremental change against the pre-commit snapshot,
persist the tx watermark + COMMIT the durable data, then deliver
Update::Changed to affected subscribers. Returns the new tx id.
Subscriber callbacks run synchronously after commit. A callback panic does not roll back the SQL transaction.
A transaction that exceeds the batch-delta memory budget still commits — it is
shed (design 306 D4): the engine rebuilds and every query re-hydrates,
subscribers receiving a replacing Update::Hydrated instead of Changed
events (see CommitInfo::shed). Any other derive error aborts the
transaction as before.
Sourcepub fn commit_with_info(self) -> Result<CommitInfo, ReplicaError>
pub fn commit_with_info(self) -> Result<CommitInfo, ReplicaError>
commit, additionally reporting the transaction’s
CommitInfo — the cv to stamp on outgoing batches. The whole capture
(including _rindle_client_mutations rows) feeds the engine; lmid flows to
clients as ordinary query data (see crate::mutations).
Trait Implementations§
Source§impl MutationSql for WriteTxn
The SQL MutationTx flavor (design §4.2): a server mutator runs against the open
single-writer transaction, reading through the same connection so it sees its own
uncommitted writes.
impl MutationSql for WriteTxn
The SQL MutationTx flavor (design §4.2): a server mutator runs against the open
single-writer transaction, reading through the same connection so it sees its own
uncommitted writes.
Source§fn exec(
&mut self,
sql: &str,
params: &[OwnedValue],
) -> Result<usize, ReplicaError>
fn exec( &mut self, sql: &str, params: &[OwnedValue], ) -> Result<usize, ReplicaError>
Source§fn query(
&mut self,
sql: &str,
params: &[OwnedValue],
) -> Result<Vec<Vec<OwnedValue>>, ReplicaError>
fn query( &mut self, sql: &str, params: &[OwnedValue], ) -> Result<Vec<Vec<OwnedValue>>, ReplicaError>
INTEGER → Int, REAL → Float, TEXT → Str, NULL → Null; BLOB is
an error). Raw classes, not the engine’s number-widening coercion — the
mutator is writing SQL, not feeding the pipeline.