Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/query/ast/src/ast/statements/system_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl Display for SystemStmt {
#[derive(Debug, Clone, PartialEq, Eq, Drive, DriveMut)]
pub enum SystemAction {
Backtrace(bool),
FlushPrivileges,
}

impl Display for SystemAction {
Expand All @@ -41,6 +42,7 @@ impl Display for SystemAction {
true => write!(f, "ENABLE EXCEPTION_BACKTRACE"),
false => write!(f, "DISABLE EXCEPTION_BACKTRACE"),
},
SystemAction::FlushPrivileges => write!(f, "FLUSH PRIVILEGES"),
}
}
}
10 changes: 8 additions & 2 deletions src/query/ast/src/parser/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5054,15 +5054,21 @@ pub fn priority(i: Input) -> IResult<Priority> {
}

pub fn action(i: Input) -> IResult<SystemAction> {
let mut backtrace = parser_fn(map(
let backtrace = parser_fn(map(
rule! {
#switch ~ EXCEPTION_BACKTRACE
},
|(switch, _)| SystemAction::Backtrace(switch),
));
let flush_privileges = parser_fn(map(
rule! {
FLUSH ~ PRIVILEGES
},
|_| SystemAction::FlushPrivileges,
));
// add other system action type here
rule!(
#backtrace
#backtrace | #flush_privileges
)
.parse(i)
}
Expand Down
2 changes: 2 additions & 0 deletions src/query/ast/src/parser/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,8 @@ pub enum TokenKind {
FORMAT_NAME,
#[token("FORMATS", ignore(ascii_case))]
FORMATS,
#[token("FLUSH", ignore(ascii_case))]
FLUSH,
#[token("FRAGMENTS", ignore(ascii_case))]
FRAGMENTS,
#[token("FRIDAY", ignore(ascii_case))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use databend_common_exception::set_backtrace;
use databend_common_exception::Result;
use databend_common_sql::plans::SystemAction;
use databend_common_sql::plans::SystemPlan;
use databend_common_users::RoleCacheManager;

use crate::clusters::ClusterHelper;
use crate::clusters::FlightParams;
Expand Down Expand Up @@ -90,6 +91,10 @@ impl Interpreter for SystemActionInterpreter {
SystemAction::Backtrace(switch) => {
set_backtrace(switch);
}
SystemAction::FlushPrivileges => {
let tenant = self.ctx.get_tenant();
RoleCacheManager::instance().force_reload(&tenant).await?;
}
}
Ok(PipelineBuildResult::create())
}
Expand Down
3 changes: 2 additions & 1 deletion src/query/service/src/servers/flight/v1/actions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ use crate::sessions::SessionManager;

pub(crate) fn create_session() -> Result<Arc<Session>> {
let config = GlobalConfig::instance();
let settings = Settings::create(config.query.tenant_id.clone());
let tenant_id = config.query.tenant_id.clone();
let settings = Settings::create(tenant_id);
match SessionManager::instance().create_with_settings(SessionType::FlightRPC, settings, None) {
Err(cause) => Err(cause),
Ok(session) => Ok(Arc::new(session)),
Expand Down
3 changes: 3 additions & 0 deletions src/query/sql/src/planner/binder/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ impl Binder {
AstSystemAction::Backtrace(switch) => Ok(Plan::System(Box::new(SystemPlan {
action: SystemAction::Backtrace(*switch),
}))),
AstSystemAction::FlushPrivileges => Ok(Plan::System(Box::new(SystemPlan {
action: SystemAction::FlushPrivileges,
}))),
}
}
}
1 change: 1 addition & 0 deletions src/query/sql/src/planner/plans/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ pub struct SystemPlan {
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub enum SystemAction {
Backtrace(bool),
FlushPrivileges,
}
5 changes: 1 addition & 4 deletions tests/nox/java_client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ def create_user():
"CREATE USER databend IDENTIFIED BY 'databend' with default_role='account_admin'"
)
exec("GRANT ROLE account_admin TO USER databend")
# need for cluster to sync the GRANT op
time.sleep(16)
for p in [8001, 8002, 8003]:
exec("SHOW GRANTS FOR USER databend", port=p)
exec("SYSTEM FLUSH PRIVILEGES")


def download_testng():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ SYSTEM ENABLE EXCEPTION_BACKTRACE;

statement ok
SYSTEM DISABLE EXCEPTION_BACKTRACE;

statement ok
SYSTEM FLUSH PRIVILEGES;
Loading