mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-23 01:16: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);
|
||||
}
|
||||
|
||||
let mut found = None;
|
||||
|
||||
visit_relations(ast, |relation| {
|
||||
let control_flow = visit_relations(ast, |relation| {
|
||||
let relation = relation.to_string();
|
||||
let table_name = relation.split('.').last().unwrap().to_string();
|
||||
|
||||
if self.tables.contains(&table_name) {
|
||||
found = Some(table_name);
|
||||
ControlFlow::<()>::Break(())
|
||||
ControlFlow::Break(table_name)
|
||||
} else {
|
||||
ControlFlow::<()>::Continue(())
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
});
|
||||
|
||||
if let Some(found) = found {
|
||||
if let ControlFlow::Break(found) = control_flow {
|
||||
debug!("Blocking access to table \"{found}\"");
|
||||
|
||||
Ok(PluginOutput::Deny(format!(
|
||||
|
||||
Reference in New Issue
Block a user