common_meta/ddl/drop_table/
metadata.rs1#[cfg(feature = "enterprise")]
16use common_catalog::consts::FILE_ENGINE;
17use common_catalog::format_full_table_name;
18use snafu::OptionExt;
19use store_api::metric_engine_consts::METRIC_ENGINE_NAME;
20
21use crate::ddl::drop_table::DropTableProcedure;
22use crate::ddl::utils::extract_region_wal_options;
23#[cfg(feature = "enterprise")]
24use crate::ddl::utils::is_metric_engine_logical_table;
25use crate::error::{self, Result};
26#[cfg(feature = "enterprise")]
27use crate::key::table_route::TableRouteValue;
28
29impl DropTableProcedure {
30 #[cfg(feature = "enterprise")]
31 fn apply_soft_drop_fallbacks(
32 &mut self,
33 table_info_value: &crate::key::table_info::TableInfoValue,
34 table_route_value: &TableRouteValue,
35 is_physical: bool,
36 ) {
37 if self.data.soft_drop_enabled
39 && is_metric_engine_logical_table(&table_info_value.table_info, table_route_value)
40 {
41 self.data.soft_drop_enabled = false;
42 }
43
44 if is_physical
45 && self.data.soft_drop_enabled
46 && table_info_value.table_info.meta.engine == FILE_ENGINE
47 {
48 self.data.soft_drop_enabled = false;
49 }
50 }
51
52 pub(crate) async fn fill_table_metadata(&mut self) -> Result<()> {
54 let task = &self.data.task;
55 let (physical_table_id, physical_table_route_value) = self
56 .context
57 .table_metadata_manager
58 .table_route_manager()
59 .get_physical_table_route(task.table_id)
60 .await?;
61
62 let table_info_value = self
63 .context
64 .table_metadata_manager
65 .table_info_manager()
66 .get(task.table_id)
67 .await?
68 .with_context(|| error::TableInfoNotFoundSnafu {
69 table: format_full_table_name(&task.catalog, &task.schema, &task.table),
70 })?
71 .into_inner();
72 #[cfg(feature = "enterprise")]
73 let table_route_value = TableRouteValue::new(
74 self.data.table_id(),
75 physical_table_id,
76 physical_table_route_value.region_routes.clone(),
77 );
78 #[cfg(feature = "enterprise")]
79 self.apply_soft_drop_fallbacks(
80 &table_info_value,
81 &table_route_value,
82 physical_table_id == self.data.table_id(),
83 );
84
85 if physical_table_id == self.data.table_id() {
86 let engine = table_info_value.table_info.meta.engine;
87 self.data.allow_rollback = engine.as_str() == METRIC_ENGINE_NAME;
89
90 let datanode_table_values = self
92 .context
93 .table_metadata_manager
94 .datanode_table_manager()
95 .regions(physical_table_id, &physical_table_route_value)
96 .await?;
97 self.data.region_wal_options = extract_region_wal_options(&datanode_table_values)?;
98 }
99
100 self.data.physical_region_routes = physical_table_route_value.region_routes;
101 self.data.physical_table_id = Some(physical_table_id);
102
103 Ok(())
104 }
105}