MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / new

Method new

src/sql-server-util/src/lib.rs:359–378  ·  view source on GitHub ↗
(client: &'a mut Client)

Source from the content-addressed store, hash-verified

357
358impl<'a> Transaction<'a> {
359 async fn new(client: &'a mut Client) -> Result<Self, SqlServerError> {
360 // Construct the guard *before* awaiting BEGIN to avoid a potential race where
361 // transaction is started on remote, but the transaction is cancelled before returning.
362 let tx = Transaction {
363 client,
364 closed: false,
365 };
366 let results = tx
367 .client
368 .simple_query("BEGIN TRANSACTION")
369 .await
370 .context("begin")?;
371 if !results.is_empty() {
372 Err(SqlServerError::InvariantViolated(format!(
373 "expected empty result from BEGIN TRANSACTION. Got: {results:?}"
374 )))
375 } else {
376 Ok(tx)
377 }
378 }
379
380 /// Creates a savepoint via `SAVE TRANSACTION` with the provided name.
381 /// Creating a savepoint forces a write to the transaction log, which will associate an

Callers

nothing calls this directly

Calls 3

contextMethod · 0.45
simple_queryMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected