uqa_engine/capabilities/
index_removal.rs1use crate::Engine;
9use uqa_core::RelationIdentity;
10use uqa_execution::schema::indexes::removal::{
11 IndexRemovalCatalog, IndexRemovalContext, IndexRemovalPrivileges, IndexRemovalPublication,
12 IndexRemovalTransactions, IndexRemovalWrite,
13};
14use uqa_sql::{ast::ColumnType, catalog::resolution::RelationResolution, SQLError, SQLResult};
15use uqa_storage::{CatalogIndexRow, StorageBackendResult};
16impl Engine {
17 pub(crate) fn index_removal_context(&self) -> IndexRemovalContext<'_> {
18 IndexRemovalContext {
19 deletion: self,
20 catalog: self,
21 privileges: self,
22 publication: self,
23 constraints: self.constraint_alter_context(),
24 transactions: self,
25 notices: self.query_runtime_view().notices,
26 }
27 }
28}
29impl IndexRemovalCatalog for Engine {
30 fn resolve_relation_kind(&self, name: &str) -> Result<RelationResolution, SQLError> {
31 self.resolve_visible_relation_kind(name)
32 }
33 fn bound_catalog_index(&self, name: &str) -> StorageBackendResult<Option<CatalogIndexRow>> {
34 Engine::bound_catalog_index(self, name)
35 }
36 fn list_catalog_indexes(&self) -> StorageBackendResult<Vec<CatalogIndexRow>> {
37 Engine::catalog_indexes_in_execution(self)
38 }
39 fn column_type(&self, table: &str, column: &str) -> StorageBackendResult<Option<ColumnType>> {
40 Engine::column_type(self, table, column)
41 }
42}
43impl IndexRemovalPrivileges for Engine {
44 fn ensure_drop_authority(&self, index: &CatalogIndexRow) -> Result<(), SQLError> {
45 self.require_index_drop_authority(index)
46 }
47}
48impl IndexRemovalPublication for Engine {
49 fn retire_diskann_index(
50 &self,
51 row: &CatalogIndexRow,
52 field: &str,
53 dimensions: u32,
54 ) -> StorageBackendResult<()> {
55 self.retire_catalog_diskann_index(row, field, dimensions)
56 }
57 fn drop_catalog_index_relation(
58 &self,
59 relation: &RelationIdentity,
60 ) -> StorageBackendResult<Option<CatalogIndexRow>> {
61 self.try_drop_catalog_index_relation(relation)
62 }
63 fn drop_fts_field(&self, table: &str, field: &str) -> Result<(), SQLError> {
64 Engine::drop_fts_field(self, table, field)
65 }
66 fn release_fts_analyzer_owner(&self, table: &str, field: &str) -> Result<(), SQLError> {
67 Engine::release_fts_analyzer_owner(self, table, field)
68 }
69 fn drop_vector_field_index(
70 &self,
71 table: &str,
72 field: String,
73 dimensions: u32,
74 ) -> StorageBackendResult<bool> {
75 Engine::drop_vector_field_index(self, table, field, dimensions)
76 }
77 fn drop_vector_index_metadata(&self, table: &str, field: &str) -> StorageBackendResult<()> {
78 Engine::drop_vector_index_metadata(self, table, field)
79 }
80}
81impl IndexRemovalTransactions for Engine {
82 fn with_index_write(&self, write: IndexRemovalWrite<'_>) -> Result<SQLResult, SQLError> {
83 self.with_implicit_transaction(|engine| {
84 let result = write(&engine.index_removal_context())?;
85 engine.publish_catalog_constraint_tuples()?;
86 Ok(result)
87 })
88 }
89}