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

Method one_query

src/pgwire/src/protocol.rs:1053–1130  ·  view source on GitHub ↗
(
        &mut self,
        stmt: Statement<Raw>,
        sql: String,
        lifecycle_timestamps: LifecycleTimestamps,
    )

Source from the content-addressed store, hash-verified

1051 /// statements in a Simple Query, then all of them have the same `lifecycle_timestamps`.
1052 #[instrument(level = "debug")]
1053 async fn one_query(
1054 &mut self,
1055 stmt: Statement<Raw>,
1056 sql: String,
1057 lifecycle_timestamps: LifecycleTimestamps,
1058 ) -> Result<State, io::Error> {
1059 // Bind the portal. Note that this does not set the empty string prepared
1060 // statement.
1061 const EMPTY_PORTAL: &str = "";
1062 if let Err(e) = self
1063 .adapter_client
1064 .declare(EMPTY_PORTAL.to_string(), stmt, sql)
1065 .await
1066 {
1067 return self
1068 .send_error_and_get_state(e.into_response(Severity::Error))
1069 .await;
1070 }
1071 let portal = self
1072 .adapter_client
1073 .session()
1074 .get_portal_unverified_mut(EMPTY_PORTAL)
1075 .expect("unnamed portal should be present");
1076
1077 *portal.lifecycle_timestamps = Some(lifecycle_timestamps);
1078
1079 let stmt_desc = portal.desc.clone();
1080 if !stmt_desc.param_types.is_empty() {
1081 return self
1082 .send_error_and_get_state(ErrorResponse::error(
1083 SqlState::UNDEFINED_PARAMETER,
1084 "there is no parameter $1",
1085 ))
1086 .await;
1087 }
1088
1089 // Maybe send row description.
1090 if let Some(relation_desc) = &stmt_desc.relation_desc {
1091 if !stmt_desc.is_copy {
1092 let formats = vec![Format::Text; stmt_desc.arity()];
1093 self.send(BackendMessage::RowDescription(
1094 message::encode_row_description(relation_desc, &formats),
1095 ))
1096 .await?;
1097 }
1098 }
1099
1100 let result = match self
1101 .adapter_client
1102 .execute(EMPTY_PORTAL.to_string(), self.conn.wait_closed(), None)
1103 .await
1104 {
1105 Ok((response, execute_started)) => {
1106 self.send_pending_notices().await?;
1107 self.send_execute_response(
1108 response,
1109 stmt_desc.relation_desc,
1110 EMPTY_PORTAL.to_string(),

Callers 1

queryMethod · 0.80

Calls 15

errorFunction · 0.85
RowDescriptionClass · 0.85
encode_row_descriptionFunction · 0.85
expectMethod · 0.80
wait_closedMethod · 0.80
send_pending_noticesMethod · 0.80
send_execute_responseMethod · 0.80
remove_portalMethod · 0.80
declareMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected