Skip to content

Commit

Permalink
[feature](merge-cloud) Disable `AlterSystemStmt/AdminShowConfigStmt/A…
Browse files Browse the repository at this point in the history
…dminSetConfigStmt` in cloud mode

* In cloud mode, node is managered by meta-servcie restful api not sql stmt
  so alter system stmt will not work
* AdminShowConfig and AdminSetConfigStmt is not allowed except root in
  cloud mode for security reason
  • Loading branch information
SWJTU-ZhangLei committed May 7, 2024
1 parent 4f290c3 commit 831d708
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.doris.analysis;

import org.apache.doris.catalog.Env;
import org.apache.doris.common.Config;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.UserException;
Expand All @@ -38,7 +39,6 @@ public AlterSystemStmt(AlterClause alterClause) {

@Override
public void analyze(Analyzer analyzer) throws UserException {

if (!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), PrivPredicate.OPERATOR)) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR,
"NODE");
Expand All @@ -58,6 +58,10 @@ public void analyze(Analyzer analyzer) throws UserException {
|| (alterClause instanceof ModifyFrontendHostNameClause)
);

if (Config.isCloudMode()) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_UNKNOWN_ERROR, "Unsupported operation");
}

alterClause.analyze(analyzer);
}

Expand Down
6 changes: 6 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
import org.apache.doris.load.loadv2.JobState;
import org.apache.doris.load.loadv2.LoadJob;
import org.apache.doris.load.sync.SyncJobManager;
import org.apache.doris.mysql.privilege.Auth;
import org.apache.doris.persist.CleanQueryStatsInfo;
import org.apache.doris.statistics.StatisticsRepository;

Expand Down Expand Up @@ -293,6 +294,11 @@ public static void execute(Env env, DdlStmt ddlStmt) throws Exception {
} else if (ddlStmt instanceof AdminCompactTableStmt) {
env.compactTable((AdminCompactTableStmt) ddlStmt);
} else if (ddlStmt instanceof AdminSetConfigStmt) {
if (Config.isCloudMode()
&& !ConnectContext.get().getCurrentUserIdentity().getUser().equals(Auth.ROOT_USER)) {
LOG.info("stmt={}, not supported in cloud mode", ddlStmt.toString());
throw new DdlException("Unsupported operation");
}
env.setConfig((AdminSetConfigStmt) ddlStmt);
} else if (ddlStmt instanceof AdminSetTableStatusStmt) {
env.setTableStatus((AdminSetTableStatusStmt) ddlStmt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ public ShowResultSet execute() throws AnalysisException {
} else if (stmt instanceof ShowReplicaDistributionStmt) {
handleAdminShowTabletDistribution();
} else if (stmt instanceof ShowConfigStmt) {
if (Config.isCloudMode() && !ctx.getCurrentUserIdentity()
.getUser().equals(Auth.ROOT_USER)) {
LOG.info("stmt={}, not supported in cloud mode", stmt.toString());
throw new AnalysisException("Unsupported operation");
}
handleAdminShowConfig();
} else if (stmt instanceof ShowSmallFilesStmt) {
handleShowSmallFiles();
Expand Down

0 comments on commit 831d708

Please sign in to comment.