mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-27 18:56:30 +00:00
simplify TableAccess::run
This commit is contained in:
@@ -30,21 +30,18 @@ impl<'a> Plugin for TableAccess<'a> {
|
|||||||
return Ok(PluginOutput::Allow);
|
return Ok(PluginOutput::Allow);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut found = None;
|
let control_flow = visit_relations(ast, |relation| {
|
||||||
|
|
||||||
visit_relations(ast, |relation| {
|
|
||||||
let relation = relation.to_string();
|
let relation = relation.to_string();
|
||||||
let table_name = relation.split('.').last().unwrap().to_string();
|
let table_name = relation.split('.').last().unwrap().to_string();
|
||||||
|
|
||||||
if self.tables.contains(&table_name) {
|
if self.tables.contains(&table_name) {
|
||||||
found = Some(table_name);
|
ControlFlow::Break(table_name)
|
||||||
ControlFlow::<()>::Break(())
|
|
||||||
} else {
|
} else {
|
||||||
ControlFlow::<()>::Continue(())
|
ControlFlow::Continue(())
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(found) = found {
|
if let ControlFlow::Break(found) = control_flow {
|
||||||
debug!("Blocking access to table \"{found}\"");
|
debug!("Blocking access to table \"{found}\"");
|
||||||
|
|
||||||
Ok(PluginOutput::Deny(format!(
|
Ok(PluginOutput::Deny(format!(
|
||||||
|
|||||||
Reference in New Issue
Block a user