This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push: new 4294301 Throw DdlException when use `admin set frontend config` (#3539) 4294301 is described below commit 4294301c53d47319fb97e84b771f6e194a3328d6 Author: WingC <1018957...@qq.com> AuthorDate: Mon May 11 10:29:38 2020 -0500 Throw DdlException when use `admin set frontend config` (#3539) The set more than one config in a single set config stmt, an exception will be thrown to forbid the operation. --- .../apache/doris/analysis/AdminSetConfigStmt.java | 3 + .../doris/analysis/AminSetConfigStmtTest.java | 73 ++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/fe/src/main/java/org/apache/doris/analysis/AdminSetConfigStmt.java b/fe/src/main/java/org/apache/doris/analysis/AdminSetConfigStmt.java index 2ed8987..1170877 100644 --- a/fe/src/main/java/org/apache/doris/analysis/AdminSetConfigStmt.java +++ b/fe/src/main/java/org/apache/doris/analysis/AdminSetConfigStmt.java @@ -70,6 +70,9 @@ public class AdminSetConfigStmt extends DdlStmt { public void analyze(Analyzer analyzer) throws AnalysisException, UserException { super.analyze(analyzer); + if (configs.size() != 1) { + throw new AnalysisException("config parameter size is not equal to 1"); + } // check auth if (!Catalog.getCurrentCatalog().getAuth().checkGlobalPriv(ConnectContext.get(), PrivPredicate.ADMIN)) { ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "ADMIN"); diff --git a/fe/src/test/java/org/apache/doris/analysis/AminSetConfigStmtTest.java b/fe/src/test/java/org/apache/doris/analysis/AminSetConfigStmtTest.java new file mode 100644 index 0000000..83e0ef3 --- /dev/null +++ b/fe/src/test/java/org/apache/doris/analysis/AminSetConfigStmtTest.java @@ -0,0 +1,73 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.analysis; + +import org.apache.doris.catalog.Catalog; +import org.apache.doris.common.AnalysisException; +import org.apache.doris.common.DdlException; +import org.apache.doris.qe.ConnectContext; +import org.apache.doris.utframe.UtFrameUtils; + +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.UUID; + +public class AdminSetConfigStmtTest { + private static String runningDir = "fe/mocked/AdminSetConfigStmtTest/" + UUID.randomUUID().toString() + "/"; + + private static ConnectContext connectContext; + + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + @BeforeClass + public static void beforeClass() throws Exception { + UtFrameUtils.createMinDorisCluster(runningDir); + + // create connect context + connectContext = UtFrameUtils.createDefaultCtx(); + } + + @Test + public void testNormal() throws Exception { + String stmt = "admin set frontend config(\"alter_table_timeout_second\" = \"60\");"; + AdminSetConfigStmt adminSetConfigStmt = (AdminSetConfigStmt) UtFrameUtils.parseAndAnalyzeStmt(stmt, connectContext); + Catalog.getCurrentCatalog().setConfig(adminSetConfigStmt); + } + + @Test + public void testUnknownConfig() throws Exception { + String stmt = "admin set frontend config(\"unknown_config\" = \"unknown\");"; + AdminSetConfigStmt adminSetConfigStmt = (AdminSetConfigStmt) UtFrameUtils.parseAndAnalyzeStmt(stmt, connectContext); + expectedEx.expect(DdlException.class); + expectedEx.expectMessage("errCode = 2, detailMessage = Config 'unknown_config' does not exist or is not mutable"); + Catalog.getCurrentCatalog().setConfig(adminSetConfigStmt); + } + + @Test + public void testEmptyConfig() throws Exception { + String stmt = "admin set frontend config;"; + expectedEx.expect(AnalysisException.class); + expectedEx.expectMessage("errCode = 2, detailMessage = config parameter size is not equal to 1"); + AdminSetConfigStmt adminSetConfigStmt = (AdminSetConfigStmt) UtFrameUtils.parseAndAnalyzeStmt(stmt, connectContext); + } +} + --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org