Skip to content

Commit 264a649

Browse files
committed
Address comments
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent 3982e68 commit 264a649

File tree

4 files changed

+6
-33
lines changed

4 files changed

+6
-33
lines changed

src/query/service/src/interpreters/access/accessor.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::collections::HashMap;
1616
use std::sync::Arc;
1717

1818
use common_exception::Result;
19-
use common_legacy_planners::PlanNode;
2019

2120
use crate::interpreters::access::PrivilegeAccess;
2221
use crate::interpreters::ManagementModeAccess;
@@ -26,11 +25,7 @@ use crate::sql::plans::Plan;
2625
#[async_trait::async_trait]
2726
pub trait AccessChecker: Sync + Send {
2827
// Check the access permission for the old plan.
29-
// TODO(bohu): Remove after new plan done.
30-
async fn check(&self, plan: &PlanNode) -> Result<()>;
31-
32-
// Check the access permission for the old plan.
33-
async fn check_new(&self, _plan: &Plan) -> Result<()>;
28+
async fn check(&self, _plan: &Plan) -> Result<()>;
3429
}
3530

3631
pub struct Accessor {
@@ -48,9 +43,9 @@ impl Accessor {
4843
Accessor { accessors }
4944
}
5045

51-
pub async fn check_new(&self, plan: &Plan) -> Result<()> {
46+
pub async fn check(&self, plan: &Plan) -> Result<()> {
5247
for accessor in self.accessors.values() {
53-
accessor.check_new(plan).await?;
48+
accessor.check(plan).await?;
5449
}
5550
Ok(())
5651
}

src/query/service/src/interpreters/access/management_mode_access.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::sync::Arc;
1616

1717
use common_exception::ErrorCode;
1818
use common_exception::Result;
19-
use common_legacy_planners::PlanNode;
2019

2120
use crate::interpreters::access::AccessChecker;
2221
use crate::sessions::QueryContext;
@@ -36,22 +35,7 @@ impl ManagementModeAccess {
3635
#[async_trait::async_trait]
3736
impl AccessChecker for ManagementModeAccess {
3837
// Check what we can do if in management mode.
39-
async fn check(&self, plan: &PlanNode) -> Result<()> {
40-
// Allows for management-mode.
41-
if self.ctx.get_config().query.management_mode {
42-
return match plan {
43-
PlanNode::Empty(_) => Ok(()),
44-
_ => Err(ErrorCode::ManagementModePermissionDenied(format!(
45-
"Access denied for operation:{:?} in management-mode",
46-
plan.name()
47-
))),
48-
};
49-
};
50-
Ok(())
51-
}
52-
53-
// Check what we can do if in management mode.
54-
async fn check_new(&self, plan: &Plan) -> Result<()> {
38+
async fn check(&self, plan: &Plan) -> Result<()> {
5539
// Allows for management-mode.
5640
if self.ctx.get_config().query.management_mode {
5741
let ok = match plan {

src/query/service/src/interpreters/access/privilege_access.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use std::sync::Arc;
1616

1717
use common_exception::Result;
18-
use common_legacy_planners::PlanNode;
1918
use common_meta_types::GrantObject;
2019
use common_meta_types::UserPrivilegeType;
2120

@@ -35,12 +34,7 @@ impl PrivilegeAccess {
3534

3635
#[async_trait::async_trait]
3736
impl AccessChecker for PrivilegeAccess {
38-
async fn check(&self, _plan: &PlanNode) -> Result<()> {
39-
// The old planner *NO* need to check anymore.
40-
Ok(())
41-
}
42-
43-
async fn check_new(&self, plan: &Plan) -> Result<()> {
37+
async fn check(&self, plan: &Plan) -> Result<()> {
4438
let session = self.ctx.get_current_session();
4539

4640
match plan {

src/query/service/src/interpreters/interpreter_factory_v2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl InterpreterFactoryV2 {
4747
pub async fn get(ctx: Arc<QueryContext>, plan: &Plan) -> Result<InterpreterPtr> {
4848
// Check the access permission.
4949
let access_checker = Accessor::create(ctx.clone());
50-
access_checker.check_new(plan).await.map_err(|e| {
50+
access_checker.check(plan).await.map_err(|e| {
5151
error!("Access.denied(v2): {:?}", e);
5252
e
5353
})?;

0 commit comments

Comments
 (0)