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