uqa_engine/capabilities/
foreign_creation.rs1use crate::Engine;
9use uqa_execution::schema::foreign_creation::{
10 entry::{ForeignCatalogWrite, ForeignCreationTransactions},
11 ForeignCreationContext, ForeignCreationNamespace, ForeignCreationRegistry, ForeignSecurityRead,
12 ForeignServersRead, ForeignServersWrite, ForeignTablesRead,
13};
14use uqa_sql::{schema::foreign_tables::ForeignSchemaContext, SQLError};
15use uqa_storage::StorageBackendResult;
16impl Engine {
17 pub(crate) fn foreign_schema_context(&self) -> ForeignSchemaContext<'_> {
18 ForeignSchemaContext {
19 types: self,
20 schema: self,
21 bindings: self,
22 references: self,
23 sequences: self,
24 }
25 }
26 pub(crate) fn foreign_creation_context(&self) -> ForeignCreationContext<'_> {
27 ForeignCreationContext {
28 routine_names: self,
29 invocation: self.routine_invocation_context(),
30 creation: self.relation_creation_context(),
31 identities: self.catalog_identity_reservation_context(),
32 schema: self.foreign_schema_context(),
33 namespace: self,
34 registry: self,
35 publication: self,
36 catalog: self.storage.catalog.as_deref(),
37 changes: self,
38 sequences: self.implicit_sequence_context(),
39 ownership: self.implicit_ownership_context(),
40 notices: self.query_runtime_view().notices,
41 allocate_identity: crate::new_table_object_id,
42 }
43 }
44}
45impl ForeignRegistryReads for Engine {
46 fn wrappers(&self) -> uqa_execution::catalog::foreign::reads::ForeignWrappersRead<'_> {
47 Box::new(self.durable.foreign_wrappers.read())
48 }
49 fn servers(&self) -> ForeignServersRead<'_> {
50 Box::new(self.durable.foreign_servers.read())
51 }
52 fn tables(&self) -> ForeignTablesRead<'_> {
53 Box::new(self.durable.foreign_tables.read())
54 }
55 fn security(&self) -> ForeignSecurityRead<'_> {
56 Box::new(self.durable.foreign_table_security.read())
57 }
58}
59impl ForeignCreationRegistry for Engine {
60 fn wrappers_write(&self) -> uqa_execution::schema::foreign_creation::ForeignWrappersWrite<'_> {
61 Box::new(self.durable.foreign_wrappers.write())
62 }
63 fn servers_write(&self) -> ForeignServersWrite<'_> {
64 Box::new(self.durable.foreign_servers.write())
65 }
66}
67impl ForeignCreationNamespace for Engine {
68 fn synchronize_catalog_registries(&self) -> StorageBackendResult<()> {
69 Engine::synchronize_catalog_registries(self)
70 }
71
72 fn relation_kind_at(&self, name: &str) -> StorageBackendResult<Option<&'static str>> {
73 Engine::relation_kind_at(self, name)
74 }
75}
76impl ForeignCreationTransactions for Engine {
77 fn with_foreign_catalog_write(&self, write: ForeignCatalogWrite<'_>) -> Result<(), SQLError> {
78 self.with_implicit_definition_transaction(|engine| {
79 write(&engine.foreign_creation_context())
80 })
81 }
82}
83
84use uqa_execution::catalog::foreign::reads::ForeignRegistryReads;