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

Method create_savepoint

src/sql-server-util/src/lib.rs:389–405  ·  view source on GitHub ↗

Creates a savepoint via `SAVE TRANSACTION` with the provided name. Creating a savepoint forces a write to the transaction log, which will associate an [`Lsn`] with the current transaction. The savepoint name must follow rules for SQL Server identifiers - starts with letter or underscore - only contains letters, digits, and underscores - no reserved words - 32 char max

(&mut self, savepoint_name: &str)

Source from the content-addressed store, hash-verified

387 /// - no reserved words
388 /// - 32 char max
389 pub async fn create_savepoint(&mut self, savepoint_name: &str) -> Result<(), SqlServerError> {
390 // Limit the name checks to prevent sending a potentially dangerous string to the SQL Server.
391 // We prefer the server do the majority of the validation.
392 if savepoint_name.is_empty()
393 || !savepoint_name
394 .chars()
395 .all(|c| c.is_alphanumeric() || c == '_')
396 {
397 Err(SqlServerError::ProgrammingError(format!(
398 "Invalid savepoint name: '{savepoint_name}"
399 )))?;
400 }
401
402 let stmt = format!("SAVE TRANSACTION {}", quote_identifier(savepoint_name));
403 let _result = self.client.simple_query(stmt).await?;
404 Ok(())
405 }
406
407 /// Retrieve the [`Lsn`] associated with the current session.
408 ///

Callers 1

snapshotMethod · 0.80

Calls 3

allMethod · 0.80
is_emptyMethod · 0.45
simple_queryMethod · 0.45

Tested by

no test coverage detected