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

Method execute

src/pgwire/src/protocol.rs:1498–1688  ·  view source on GitHub ↗

`outer_ctx_extra` is Some when we are executing as part of an outer statement, e.g., a FETCH triggering the execution of the underlying query.

(
        &mut self,
        portal_name: String,
        max_rows: ExecuteCount,
        get_response: GetResponse,
        fetch_portal_name: Option<String>,
        timeout: ExecuteTimeout,
       

Source from the content-addressed store, hash-verified

1496 /// `outer_ctx_extra` is Some when we are executing as part of an outer statement, e.g., a FETCH
1497 /// triggering the execution of the underlying query.
1498 fn execute(
1499 &mut self,
1500 portal_name: String,
1501 max_rows: ExecuteCount,
1502 get_response: GetResponse,
1503 fetch_portal_name: Option<String>,
1504 timeout: ExecuteTimeout,
1505 outer_ctx_extra: Option<ExecuteContextGuard>,
1506 received: Option<EpochMillis>,
1507 ) -> BoxFuture<'_, Result<State, io::Error>> {
1508 async move {
1509 let aborted_txn = self.is_aborted_txn();
1510
1511 // Check if the portal has been started and can be continued.
1512 let portal = match self
1513 .adapter_client
1514 .session()
1515 .get_portal_unverified_mut(&portal_name)
1516 {
1517 Some(portal) => portal,
1518 None => {
1519 let msg = format!("portal {} does not exist", portal_name.quoted());
1520 if let Some(outer_ctx_extra) = outer_ctx_extra {
1521 self.adapter_client.retire_execute(
1522 outer_ctx_extra,
1523 StatementEndedExecutionReason::Errored { error: msg.clone() },
1524 );
1525 }
1526 return self
1527 .send_error_and_get_state(ErrorResponse::error(
1528 SqlState::INVALID_CURSOR_NAME,
1529 msg,
1530 ))
1531 .await;
1532 }
1533 };
1534
1535 *portal.lifecycle_timestamps = received.map(LifecycleTimestamps::new);
1536
1537 // In an aborted transaction, reject all commands except COMMIT/ROLLBACK.
1538 let txn_exit_stmt = is_txn_exit_stmt(portal.stmt.as_deref());
1539 if aborted_txn && !txn_exit_stmt {
1540 if let Some(outer_ctx_extra) = outer_ctx_extra {
1541 self.adapter_client.retire_execute(
1542 outer_ctx_extra,
1543 StatementEndedExecutionReason::Errored {
1544 error: ABORTED_TXN_MSG.to_string(),
1545 },
1546 );
1547 }
1548 return self.aborted_txn_error().await;
1549 }
1550
1551 let row_desc = portal.desc.relation_desc.clone();
1552 match portal.state {
1553 PortalState::NotStarted => {
1554 // Start a transaction if we aren't in one.
1555 self.ensure_transaction(1, "execute").await?;

Callers 6

advance_readyMethod · 0.45
one_queryMethod · 0.45
fetchMethod · 0.45
executeFunction · 0.45
execute_preparedFunction · 0.45
pg_execute_preparedFunction · 0.45

Calls 15

errorFunction · 0.85
boxedMethod · 0.80
is_aborted_txnMethod · 0.80
retire_executeMethod · 0.80
aborted_txn_errorMethod · 0.80
ensure_transactionMethod · 0.80
wait_closedMethod · 0.80
send_pending_noticesMethod · 0.80
send_execute_responseMethod · 0.80
expectMethod · 0.80

Tested by

no test coverage detected