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

Method prepare

src/adapter/src/client.rs:700–730  ·  view source on GitHub ↗

Saves the parsed statement as a prepared statement. The prepared statement is saved in the connection's [`crate::session::Session`] under the specified name.

(
        &mut self,
        name: String,
        stmt: Option<Statement<Raw>>,
        sql: String,
        param_types: Vec<Option<SqlScalarType>>,
    )

Source from the content-addressed store, hash-verified

698 /// The prepared statement is saved in the connection's [`crate::session::Session`]
699 /// under the specified name.
700 pub async fn prepare(
701 &mut self,
702 name: String,
703 stmt: Option<Statement<Raw>>,
704 sql: String,
705 param_types: Vec<Option<SqlScalarType>>,
706 ) -> Result<(), AdapterError> {
707 let catalog = self.catalog_snapshot("prepare").await;
708
709 // Note: This failpoint is used to simulate a request outliving the external connection
710 // that made it.
711 let mut async_pause = false;
712 (|| {
713 fail::fail_point!("async_prepare", |val| {
714 async_pause = val.map_or(false, |val| val.parse().unwrap_or(false))
715 });
716 })();
717 if async_pause {
718 tokio::time::sleep(Duration::from_secs(1)).await;
719 };
720
721 let desc = Coordinator::describe(&catalog, self.session(), stmt.clone(), param_types)?;
722 let now = self.now();
723 let state_revision = StateRevision {
724 catalog_revision: catalog.transient_revision(),
725 session_state_revision: self.session().state_revision(),
726 };
727 self.session()
728 .set_prepared_statement(name, stmt, sql, desc, state_revision, now);
729 Ok(())
730 }
731
732 /// Binds a statement to a portal.
733 #[mz_ore::instrument(level = "debug")]

Callers 15

parseMethod · 0.45
get_all_timelinesMethod · 0.45
try_run_sqlFunction · 0.45
run_version_checkFunction · 0.45
run_set_from_sqlFunction · 0.45
run_skip_ifFunction · 0.45
run_queryFunction · 0.45
execute_stmtFunction · 0.45
run_throttling_testFunction · 0.45
test_bind_paramsFunction · 0.45
update_filesFunction · 0.45

Calls 9

sleepFunction · 0.85
transient_revisionMethod · 0.80
state_revisionMethod · 0.80
describeFunction · 0.70
catalog_snapshotMethod · 0.45
sessionMethod · 0.45
cloneMethod · 0.45
nowMethod · 0.45

Tested by 3

run_throttling_testFunction · 0.36
test_bind_paramsFunction · 0.36