`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,
| 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?; |
no test coverage detected