This is an automated email from the ASF dual-hosted git repository. lide pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 3bc09e55f67 [Improvement](unset_variable) add docs for unset-variable stmt and update privilege check (#27672) 3bc09e55f67 is described below commit 3bc09e55f673eaded220e117758a9350a6c7272c Author: Yulei-Yang <yulei.yang0...@gmail.com> AuthorDate: Wed Nov 29 10:30:18 2023 +0800 [Improvement](unset_variable) add docs for unset-variable stmt and update privilege check (#27672) --- .../UNSET-VARIABLE.md | 79 +++++++++++++++++++++ .../UNSET-VARIABLE.md | 82 ++++++++++++++++++++++ .../apache/doris/analysis/UnsetVariableStmt.java | 12 ++++ 3 files changed, 173 insertions(+) diff --git a/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/UNSET-VARIABLE.md b/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/UNSET-VARIABLE.md new file mode 100644 index 00000000000..6e719bfbb77 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-reference/Database-Administration-Statements/UNSET-VARIABLE.md @@ -0,0 +1,79 @@ +--- +{ + "title": "UNSET-VARIABLE", + "language": "en" +} +--- + +<!-- +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. +--> + +<version since="dev"> + +## UNSET-VARIABLE + +</version> + +### Name + +UNSET VARIABLE + +### Description + +This statement is used to restore Doris system variables. These system variables can be modified at global or session level. + +grammar: + +```sql +UNSET [SESSION|GLOBAL] VARIABLE (variable_name | ALL) +```` + +illustrate: + +1. (variable_name | ALL): statement must be ended with a variable name or keyword `ALL`. + +> Note: +> +> 1. Only ADMIN users can unset variables to take effect globally +> 2. When restore a variable with `GLOBAL`, it only affect your current using session and new open sessions. It does not affect other current open sessions. + +### Example + +1. Restore value of the time zone + + ```` + UNSET VARIABLE time_zone; + ```` + +2. Restore the global execution memory size + + ```` + UNSET GLOBAL VARIABLE exec_mem_limit; + ```` +3. Restore all variables globally + + ``` + UNSET GLOBAL VARIABLE ALL; + ``` +### Keywords + + UNSET, VARIABLE + +### Best Practice + diff --git a/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/UNSET-VARIABLE.md b/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/UNSET-VARIABLE.md new file mode 100644 index 00000000000..f0c6718f4e3 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-reference/Database-Administration-Statements/UNSET-VARIABLE.md @@ -0,0 +1,82 @@ +--- +{ + "title": "UNSET-VARIABLE", + "language": "zh-CN" +} +--- + +<!-- +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. +--> + +<version since="dev"> + +## UNSET-VARIABLE + +</version> + +### Name + +UNSET VARIABLE + +### Description + +该语句主要是用来恢复 Doris 系统变量为默认值,可以是全局也可以是会话级别。 + +语法: + +```sql +UNSET [SESSION|GLOBAL] VARIABLE (variable_name | ALL) +``` + +说明: + +1. (variable_name | ALL) :必须指定变量名或使用 ALL , ALL 会恢复所有变量的值。 + +> 注意: +> +> 1. 只有 ADMIN 用户可以全局得恢复变量的值。 +> 2. 使用 `GLOBAL` 恢复变量值时仅在执行命令的当前会话和之后打开的会话中生效,不会恢复当前已有的其它会话中的值。 + + +### Example + +1. 恢复时区为默认值东八区 + + ``` + UNSET VARIABLE time_zone; + ``` + +2. 恢复全局的执行内存大小 + + ``` + UNSET GLOBAL VARIABLE exec_mem_limit; + ``` + +3. 从全局范围恢复所有变量的值 + + ``` + UNSET GLOBAL VARIABLE ALL; + ``` + +### Keywords + + UNSET, VARIABLE + +### Best Practice + diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/UnsetVariableStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/UnsetVariableStmt.java index 1f456eb5b7a..2b05e233338 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/UnsetVariableStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/UnsetVariableStmt.java @@ -17,8 +17,13 @@ package org.apache.doris.analysis; +import org.apache.doris.catalog.Env; import org.apache.doris.common.AnalysisException; +import org.apache.doris.common.ErrorCode; +import org.apache.doris.common.ErrorReport; import org.apache.doris.common.UserException; +import org.apache.doris.mysql.privilege.PrivPredicate; +import org.apache.doris.qe.ConnectContext; import com.amazonaws.util.StringUtils; @@ -65,6 +70,13 @@ public class UnsetVariableStmt extends StatementBase { if (StringUtils.isNullOrEmpty(variable) && !applyToAll) { throw new AnalysisException("You should specific the unset variable."); } + + if (setType == SetType.GLOBAL) { + if (!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), PrivPredicate.ADMIN)) { + ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, + "ADMIN"); + } + } } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org