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 rows: self.mutation_row_context(),
47 catalog: self,
48 routines: self,
49 relational: self.relational_context(),
50 }
51 }
52}