uqa_engine/capabilities/
returning.rs1use crate::{session::StatementReadSnapshot, Engine};
9use uqa_execution::mutation::returning::ReturningExecutionContext;
10use uqa_sql::{
11 ast::ColumnDef,
12 binding::snapshot::BindingSnapshot,
13 semantics::returning::{ReturningAnalysisContext, ReturningCatalog, ReturningScope},
14 RowSchema, SQLError,
15};
16impl ReturningCatalog for Engine {
17 fn try_describe_table_row_type(&self, table: &str) -> Result<Option<Vec<ColumnDef>>, String> {
18 Engine::try_describe_table_row_type(self, table).map_err(|error| error.to_string())
19 }
20 fn try_table_columns(&self, table: &str) -> Result<Vec<String>, String> {
21 Engine::table_columns_in_execution(self, table).map_err(|error| error.to_string())
22 }
23 fn view_schema(&self, table: &str) -> Result<Option<RowSchema>, SQLError> {
24 Engine::view_schema(self, table)
25 }
26}
27impl ReturningScope for Engine {
28 fn binding_snapshot(&self) -> Result<BindingSnapshot, SQLError> {
29 let scope = super::query_scope::new_for_current_routine(self);
30 uqa_execution::query::binding::binding_context(&scope).map(BindingSnapshot::from)
31 }
32}
33impl Engine {
34 pub(crate) fn returning_analysis_context(&self) -> ReturningAnalysisContext<'_> {
35 ReturningAnalysisContext {
36 catalog: self,
37 routines: self,
38 aggregates: self,
39 scope: self,
40 }
41 }
42 pub(crate) fn returning_execution_context(
43 &self,
44 ) -> ReturningExecutionContext<'_, StatementReadSnapshot> {
45 ReturningExecutionContext {
46 destination: None,
47 rows: self.mutation_row_context(),
48 catalog: self,
49 routines: self,
50 relational: self.relational_context(),
51 }
52 }
53}
54
55impl uqa_execution::mutation::returning::ReturningInputs<StatementReadSnapshot> for Engine {
56 fn returning_execution_context(
57 &self,
58 ) -> uqa_execution::mutation::returning::ReturningExecutionContext<'_, StatementReadSnapshot>
59 {
60 Engine::returning_execution_context(self)
61 }
62 fn returning_analysis_context(
63 &self,
64 ) -> uqa_sql::semantics::returning::ReturningAnalysisContext<'_> {
65 Engine::returning_analysis_context(self)
66 }
67}