uqa_engine/capabilities/
portals.rs1use crate::{session::StatementReadSnapshot, Engine};
10use uqa_execution::statement::{
11 context::session::StatementPortals,
12 portal::{
13 context::{PortalExecutionContext, PortalReturningInputs},
14 SessionPortalCommandDeclaration, SessionPortalDeclaration,
15 },
16};
17use uqa_sql::{ast::FetchCursorStmt, SQLError, SQLResult};
18
19impl Engine {
20 pub(crate) fn portal_execution_context(
21 &self,
22 ) -> PortalExecutionContext<'_, StatementReadSnapshot> {
23 PortalExecutionContext {
24 state: self,
25 queries: self,
26 returning: self,
27 command_scopes: self,
28 routines: self,
29 overloads: self,
30 types: self,
31 session: self,
32 explain: uqa_planner::explain::run_explain,
33 source_sql: None,
34 created_at_micros: self.statement_timestamp_micros(),
35 }
36 }
37}
38
39impl PortalReturningInputs<StatementReadSnapshot> for Engine {
40 fn returning_execution_context(
41 &self,
42 ) -> uqa_execution::mutation::returning::ReturningExecutionContext<'_, StatementReadSnapshot>
43 {
44 Engine::returning_execution_context(self)
45 }
46 fn returning_analysis_context(
47 &self,
48 ) -> uqa_sql::semantics::returning::ReturningAnalysisContext<'_> {
49 Engine::returning_analysis_context(self)
50 }
51}
52
53impl StatementPortals for Engine {
54 fn in_transaction_block(&self) -> bool {
55 Engine::in_transaction_block(self)
56 }
57 fn ensure_session_portal_available(&self, name: &str) -> Result<(), SQLError> {
58 Engine::ensure_session_portal_available(self, name)
59 }
60 fn open_pending_session_portal(
61 &self,
62 declaration: SessionPortalDeclaration,
63 ) -> Result<(), SQLError> {
64 Engine::open_pending_session_portal(self, declaration)
65 }
66 fn open_pending_command_session_portal(
67 &self,
68 declaration: SessionPortalCommandDeclaration,
69 ) -> Result<(), SQLError> {
70 Engine::open_pending_command_session_portal(self, declaration)
71 }
72 fn fetch_session_portal(&self, fetch: &FetchCursorStmt) -> Result<SQLResult, SQLError> {
73 Engine::fetch_session_portal(self, fetch)
74 }
75 fn close_session_portal(&self, name: &str) -> Result<(), SQLError> {
76 Engine::close_session_portal(self, name)
77 }
78 fn close_all_session_portals(&self) {
79 Engine::close_all_session_portals(self);
80 }
81}
82
83impl Engine {
84 pub(crate) fn portal_binding_context(
85 &self,
86 ) -> uqa_sql::binding::portals::PortalBindingContext<'_> {
87 uqa_sql::binding::portals::PortalBindingContext {
88 catalog: self,
89 routines: self,
90 transitions: self,
91 }
92 }
93}
94
95impl uqa_sql::binding::portals::PortalRelationCatalog for Engine {
96 fn try_resolve_table_name(&self, name: &str) -> Result<Option<String>, String> {
97 Engine::try_resolve_table_name(self, name).map_err(|error| error.to_string())
98 }
99 fn hierarchy_scan_tables(
100 &self,
101 table: &str,
102 include_descendants: bool,
103 ) -> Result<Vec<String>, SQLError> {
104 Engine::hierarchy_scan_tables(self, table, include_descendants)
105 }
106 fn view_plan(&self, name: &str) -> Result<Option<uqa_sql::plan::QueryPlan>, SQLError> {
107 Engine::view_plan(self, name)
108 }
109 fn try_resolve_visible_relation_kind(
110 &self,
111 name: &str,
112 ) -> Result<Option<(String, &'static str)>, SQLError> {
113 Engine::try_resolve_visible_relation_kind(self, name)
114 }
115 fn resolve_age_label_relation_name(&self, name: &str) -> Result<Option<String>, SQLError> {
116 uqa_execution::catalog::projection::resolve_age_label_relation_name(
117 &self.catalog_execution(),
118 name,
119 )
120 }
121 fn try_resolve_sequence_reference(&self, name: &str) -> Result<Option<String>, String> {
122 Engine::try_resolve_sequence_oid_reference_for_binding(self, name)
123 .map_err(|error| error.to_string())
124 }
125}
126
127impl uqa_sql::binding::portals::PortalTransitionRelations for Engine {
128 fn active_transition_relation_names(&self) -> std::collections::BTreeSet<String> {
129 uqa_execution::mutation::triggers::current_transition_relation_names()
130 }
131}