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/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 8b66e4a59f2 [fix](variable) fix unset global variable in non-master FE
(#58285)
8b66e4a59f2 is described below
commit 8b66e4a59f217fed8e5302da00cd82828dad8a54
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Wed Nov 26 11:28:49 2025 +0800
[fix](variable) fix unset global variable in non-master FE (#58285)
### What problem does this PR solve?
Problem Summary:
When executing `unset global variable xxx` in non-master FE.
if `xxx` is a global variable, it will return error:
```
mysql> unset global variable enable_nested_namespace;
ERROR 1105 (HY000): errCode = 2, detailMessage = Variable
'enable_nested_namespace' is a GLOBAL variable and should be set with SET GLOBAL
```
---
.../doris/nereids/trees/plans/commands/UnsetVariableCommand.java | 8 +++++++-
fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java | 4 ++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UnsetVariableCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UnsetVariableCommand.java
index 646943bece2..186e4154e73 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UnsetVariableCommand.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/UnsetVariableCommand.java
@@ -33,6 +33,7 @@ import
org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.StmtExecutor;
import org.apache.doris.qe.VariableMgr;
+import org.apache.doris.qe.VariableMgr.VarContext;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
@@ -125,7 +126,12 @@ public class UnsetVariableCommand extends Command
implements Forward {
}
SetVar var = new SetVar(SetType.SESSION, getVariable(),
new StringLiteral(defaultValue),
SetVar.SetVarType.SET_SESSION_VAR);
- VariableMgr.setVar(context.getSessionVariable(), var);
+ VarContext varCtx = VariableMgr.getVarContext(var.getVariable());
+ // only unset for session variable.
+ // If this is a global variable, no need to do this because it has
been synced from editlog already.
+ if (varCtx != null && (varCtx.getFlag() & VariableMgr.SESSION) !=
0) {
+ VariableMgr.setVar(context.getSessionVariable(), var);
+ }
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
index c2357e937a0..b3d5fc10bd9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
@@ -319,7 +319,7 @@ public class VariableMgr {
}
@Nullable
- private static VarContext getVarContext(String name) {
+ public static VarContext getVarContext(String name) {
String varName = name;
boolean hasExpPrefix = false;
if (varName.startsWith(VariableAnnotation.EXPERIMENTAL.getPrefix())) {
@@ -893,7 +893,7 @@ public class VariableMgr {
boolean affectQueryResult() default false;
}
- private static class VarContext {
+ public static class VarContext {
private Field field;
private Object obj;
private int flag;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]