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>>,
)
| 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")] |