Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
yufan022 committed Feb 10, 2023
1 parent 5e2620c commit 17a4d19
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/query/service/src/interpreters/access/privilege_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ use std::sync::Arc;
use common_exception::Result;
use common_meta_app::principal::GrantObject;
use common_meta_app::principal::UserPrivilegeType;
use common_sql::TableEntry;

use crate::interpreters::access::AccessChecker;
use crate::sessions::QueryContext;
use crate::sessions::Session;
use crate::sql::plans::Plan;

pub struct PrivilegeAccess {
Expand All @@ -34,19 +32,6 @@ impl PrivilegeAccess {
}
}

async fn validate_query_privilege(session: &Arc<Session>, table: &&TableEntry) -> Result<()> {
session
.validate_privilege(
&GrantObject::Table(
table.catalog().to_string(),
table.database().to_string(),
table.name().to_string(),
),
UserPrivilegeType::Select,
)
.await
}

#[async_trait::async_trait]
impl AccessChecker for PrivilegeAccess {
async fn check(&self, plan: &Plan) -> Result<()> {
Expand All @@ -59,7 +44,16 @@ impl AccessChecker for PrivilegeAccess {
if table.is_source_of_view() {
continue;
}
validate_query_privilege(&session, &table).await?;
session
.validate_privilege(
&GrantObject::Table(
table.catalog().to_string(),
table.database().to_string(),
table.name().to_string(),
),
UserPrivilegeType::Select,
)
.await?
}
}
Plan::Explain { .. } => {}
Expand Down

0 comments on commit 17a4d19

Please sign in to comment.