This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new 45786882ede branch-4.1: [fix](show variables) Fix changed variable
output in show variables #63734 (#63793)
45786882ede is described below
commit 45786882eded7458ccc277cfdca9d7d6c2d08ba6
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri May 29 14:30:59 2026 +0800
branch-4.1: [fix](show variables) Fix changed variable output in show
variables #63734 (#63793)
Cherry-picked from #63734
Co-authored-by: yujun <[email protected]>
---
.../doris/nereids/parser/LogicalPlanBuilder.java | 38 +++++++++++-----------
.../apache/doris/service/FrontendServiceImpl.java | 15 ++++++++-
.../ddl/show_variables/show_variables_command.out | 8 +++++
.../show_variables/show_variables_command.groovy | 8 +++++
4 files changed, 49 insertions(+), 20 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 4187eb6e681..7e2fa20cd2b 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -6524,28 +6524,28 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
@Override
public LogicalPlan visitShowVariables(ShowVariablesContext ctx) {
SetType statementScope = visitStatementScope(ctx.statementScope());
- if (ctx.wildWhere() != null) {
- if (ctx.wildWhere().LIKE() != null) {
- return new ShowVariablesCommand(statementScope,
-
stripQuotes(ctx.wildWhere().STRING_LITERAL().getText()));
+ LogicalPlan plan;
+ if (ctx.wildWhere() == null) {
+ plan = new ShowVariablesCommand(statementScope, null);
+ } else if (ctx.wildWhere().LIKE() != null) {
+ plan = new ShowVariablesCommand(statementScope,
+ stripQuotes(ctx.wildWhere().STRING_LITERAL().getText()));
+ } else {
+ StringBuilder sb = new StringBuilder();
+ sb.append("SELECT `VARIABLE_NAME` AS `Variable_name`,
`VARIABLE_VALUE` AS `Value` FROM ");
+
sb.append("`").append(InternalCatalog.INTERNAL_CATALOG_NAME).append("`");
+ sb.append(".");
+ sb.append("`").append(InfoSchemaDb.DATABASE_NAME).append("`");
+ sb.append(".");
+ if (statementScope == SetType.GLOBAL) {
+ sb.append("`global_variables` ");
} else {
- StringBuilder sb = new StringBuilder();
- sb.append("SELECT `VARIABLE_NAME` AS `Variable_name`,
`VARIABLE_VALUE` AS `Value` FROM ");
-
sb.append("`").append(InternalCatalog.INTERNAL_CATALOG_NAME).append("`");
- sb.append(".");
- sb.append("`").append(InfoSchemaDb.DATABASE_NAME).append("`");
- sb.append(".");
- if (statementScope == SetType.GLOBAL) {
- sb.append("`global_variables` ");
- } else {
- sb.append("`session_variables` ");
- }
- sb.append(getOriginSql(ctx.wildWhere()));
- return new NereidsParser().parseSingle(sb.toString());
+ sb.append("`session_variables` ");
}
- } else {
- return new ShowVariablesCommand(statementScope, null);
+ sb.append(getOriginSql(ctx.wildWhere()));
+ plan = new NereidsParser().parseSingle(sb.toString());
}
+ return plan;
}
@Override
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
index 99dd56cbe42..3957eec4474 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
@@ -121,6 +121,7 @@ import org.apache.doris.qe.MysqlConnectProcessor;
import org.apache.doris.qe.NereidsCoordinator;
import org.apache.doris.qe.QeProcessorImpl;
import org.apache.doris.qe.QueryState;
+import org.apache.doris.qe.SessionVariable;
import org.apache.doris.qe.StmtExecutor;
import org.apache.doris.qe.VariableMgr;
import org.apache.doris.service.arrowflight.FlightSqlConnectProcessor;
@@ -992,7 +993,19 @@ public class FrontendServiceImpl implements
FrontendService.Iface {
if (ctx == null) {
return result;
}
- vars = VariableMgr.dump(SetType.fromThrift(params.getVarType()),
ctx.getSessionVariable(), null);
+ // SHOW VARIABLES can be evaluated through an internal schema query.
Planning that
+ // internal query may call setVarOnce() and temporarily change the
live session
+ // variable (for example disable_join_reorder). Cloning alone is not
enough,
+ // because the clone would keep both the temporary value and its
recorded origin.
+ // Revert only the clone so Changed reflects user-visible session
settings,
+ // while the real session remains untouched.
+ SessionVariable sessionVariable =
VariableMgr.cloneSessionVariable(ctx.getSessionVariable());
+ try {
+ VariableMgr.revertSessionValue(sessionVariable);
+ } catch (DdlException e) {
+ throw new TException(e);
+ }
+ vars = VariableMgr.dump(SetType.fromThrift(params.getVarType()),
sessionVariable, null);
result.setVariables(vars);
return result;
}
diff --git
a/regression-test/data/nereids_p0/ddl/show_variables/show_variables_command.out
b/regression-test/data/nereids_p0/ddl/show_variables/show_variables_command.out
index dc009a38e77..ef1e17cb312 100644
---
a/regression-test/data/nereids_p0/ddl/show_variables/show_variables_command.out
+++
b/regression-test/data/nereids_p0/ddl/show_variables/show_variables_command.out
@@ -8,3 +8,11 @@ license Apache License, Version 2.0
-- !cmd --
license Apache License, Version 2.0
+-- !changed --
+enable_profile true
+
+-- !not_changed --
+
+-- !global --
+license Apache License, Version 2.0
+
diff --git
a/regression-test/suites/nereids_p0/ddl/show_variables/show_variables_command.groovy
b/regression-test/suites/nereids_p0/ddl/show_variables/show_variables_command.groovy
index 77caf22cacd..8b517b6708f 100644
---
a/regression-test/suites/nereids_p0/ddl/show_variables/show_variables_command.groovy
+++
b/regression-test/suites/nereids_p0/ddl/show_variables/show_variables_command.groovy
@@ -20,7 +20,15 @@ suite("show_variables_command") {
checkNereidsExecute("""show variables like 'li_ense'""")
checkNereidsExecute("""show variables where variable_name like
'li_ense'""")
checkNereidsExecute("""show variables where variable_name = 'license'""")
+ checkNereidsExecute("""show variables where changed = 1""")
+ checkNereidsExecute("""show global variables where variable_name =
'license'""")
qt_cmd("""show variables like 'li_ense'""")
qt_cmd("""show variables where variable_name like 'li_ense'""")
qt_cmd("""show variables where variable_name = 'license'""")
+
+ sql "set enable_profile = true"
+ qt_changed("""show variables where changed = 1 and variable_name =
'enable_profile'""")
+ qt_not_changed("""show variables where changed = 1 and variable_name =
'license'""")
+ qt_global("""show global variables where variable_name = 'license'""")
+ sql "UNSET VARIABLE ALL"
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]