Skip to content

Commit

Permalink
[improvement](statistics)User admin instead of root to run stats sql. (
Browse files Browse the repository at this point in the history
…#40867)

User admin instead of root to run stats sql.
  • Loading branch information
Jibing-Li authored Sep 18, 2024
1 parent 8c97aa1 commit 5c9ac9a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public static void checkDatabase(String dbName, ConnectContext ctx) throws Analy
if (!FeConstants.INTERNAL_DB_NAME.equals(dbName)) {
return;
}
if (ctx == null || ctx.getCurrentUserIdentity() == null || !ctx.getCurrentUserIdentity().isRootUser()) {
if (ctx == null || ctx.getCurrentUserIdentity() == null
|| !ctx.getCurrentUserIdentity().isRootUser() && !ctx.getCurrentUserIdentity().isAdminUser()) {
throw new AnalysisException("Not allowed to operate database: " + dbName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ public static AutoCloseConnectContext buildConnectContext(boolean limitScan, boo
sessionVariable.enableMaterializedViewRewrite = false;
connectContext.setEnv(Env.getCurrentEnv());
connectContext.setDatabase(FeConstants.INTERNAL_DB_NAME);
connectContext.setQualifiedUser(UserIdentity.ROOT.getQualifiedUser());
connectContext.setCurrentUserIdentity(UserIdentity.ROOT);
connectContext.setQualifiedUser(UserIdentity.ADMIN.getQualifiedUser());
connectContext.setCurrentUserIdentity(UserIdentity.ADMIN);
connectContext.setStartTime();
if (Config.isCloudMode()) {
AutoCloseConnectContext ctx = new AutoCloseConnectContext(connectContext);
Expand Down

0 comments on commit 5c9ac9a

Please sign in to comment.