uqa_engine/capabilities/
range_types.rs1use crate::Engine;
10use uqa_execution::catalog::range_type::{
11 RangeRegistry, RangeRegistryPublication, RangeRegistryRead,
12};
13
14impl Engine {
15 pub(crate) fn range_input_context<'a>(
16 &'a self,
17 catalog: &'a uqa_execution::catalog::CatalogReadView,
18 expressions: &'a dyn uqa_sql::expr::EngineHook,
19 ) -> uqa_execution::catalog::range_type::input::RangeInputContext<'a> {
20 uqa_execution::catalog::range_type::input::RangeInputContext {
21 catalog,
22 expressions,
23 canonical: self,
24 states: Some(&self.session.range_comparison_states),
25 }
26 }
27
28 pub(crate) fn restore_ranges_from_catalog(
29 &self,
30 catalog: &dyn uqa_storage::CatalogFacade,
31 ) -> uqa_storage::StorageBackendResult<()> {
32 *self.durable.ranges.write() =
33 uqa_execution::catalog::range_type::restore(catalog, &self.durable.roles.read())?;
34 Ok(())
35 }
36}
37
38impl uqa_execution::catalog::range_type::input::RangeCanonicalInvocation for Engine {
39 fn invoke_canonical(
40 &self,
41 catalog: &uqa_execution::catalog::CatalogReadView,
42 oid: u32,
43 value: &uqa_core::Value,
44 control: &uqa_core::memory::ProductionControl<'_>,
45 ) -> Result<uqa_core::memory::Produced<uqa_core::Value>, uqa_sql::SQLError> {
46 uqa_execution::routines::invocation::call_range_canonical(
47 &self.routine_invocation_context(),
48 catalog,
49 oid,
50 value,
51 control,
52 )
53 }
54}
55
56impl RangeRegistryPublication for Engine {
57 fn range_registry(&self) -> RangeRegistryRead<'_> {
58 Box::new(self.durable.ranges.read())
59 }
60
61 fn range_catalog(&self) -> Option<&dyn uqa_storage::CatalogFacade> {
62 self.storage.catalog.as_deref()
63 }
64
65 fn range_catalog_snapshot(&self) -> uqa_execution::catalog::CatalogReadView {
66 self.restored_catalog_read_view()
67 }
68
69 fn range_role_definitions(
70 &self,
71 ) -> std::collections::BTreeMap<String, uqa_sql::catalog::roles::RoleDefinition> {
72 self.durable.roles.read().clone()
73 }
74
75 fn publish_range_definitions(&self, registry: RangeRegistry) {
76 *self.durable.ranges.write() = registry;
77 }
78}