Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.apache.doris.analysis.SelectStmt;
import org.apache.doris.analysis.SetOperationStmt;
import org.apache.doris.analysis.SetStmt;
import org.apache.doris.analysis.SetType;
import org.apache.doris.analysis.SetVar;
import org.apache.doris.analysis.SetVar.SetVarType;
import org.apache.doris.analysis.ShowStmt;
Expand Down Expand Up @@ -936,6 +937,19 @@ private void forwardToMaster() throws Exception {
for (SetVar var : setStmt.getSetVars()) {
VariableMgr.setVarForNonMasterFE(context.getSessionVariable(), var);
}
} else if (parsedStmt instanceof UnsetVariableStmt) {
UnsetVariableStmt unsetStmt = (UnsetVariableStmt) parsedStmt;
if (unsetStmt.isApplyToAll()) {
VariableMgr.setAllVarsToDefaultValue(context.getSessionVariable(), SetType.SESSION);
} else {
String defaultValue = VariableMgr.getDefaultValue(unsetStmt.getVariable());
if (defaultValue == null) {
ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_SYSTEM_VARIABLE, unsetStmt.getVariable());
}
SetVar var = new SetVar(SetType.SESSION, unsetStmt.getVariable(),
new StringLiteral(defaultValue), SetVarType.SET_SESSION_VAR);
VariableMgr.setVar(context.getSessionVariable(), var);
}
}
}

Expand Down
20 changes: 7 additions & 13 deletions fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -713,21 +713,15 @@ public static void setAllVarsToDefaultValue(SessionVariable sessionVariable, Set
throws DdlException {
for (Map.Entry<String, VarContext> entry : ctxByDisplayVarName.entrySet()) {
VarContext varCtx = entry.getValue();

SetType newSetType = null;
// some variables are GLOBAL only or SESSION only
if ((varCtx.getFlag() & GLOBAL) != 0) {
newSetType = SetType.GLOBAL;
} else if ((varCtx.getFlag() & SESSION_ONLY) != 0) {
newSetType = SetType.SESSION;
}

SetVar setVar = new SetVar(newSetType != null ? newSetType : setType, entry.getKey(),
SetVar setVar = new SetVar(setType, entry.getKey(),
new StringLiteral(varCtx.defaultValue), SetVarType.SET_SESSION_VAR);
//skip read only variables
if ((varCtx.getFlag() & READ_ONLY) == 0) {
setVar(sessionVariable, setVar);
try {
checkUpdate(setVar, varCtx.getFlag());
} catch (DdlException e) {
LOG.debug("no need to set var for non master fe: {}", setVar.getVariable(), e);
continue;
}
setVarInternal(sessionVariable, setVar, varCtx);
}
}

Expand Down