[fix](fe) Fix UnsetVariableStmt write editlog in non master node (#31080)
* Problem introduced by https://github.com/apache/doris/pull/27552
This commit is contained in:
@ -56,6 +56,7 @@ import org.apache.doris.analysis.ReplaceTableClause;
|
||||
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;
|
||||
@ -954,6 +955,19 @@ public class StmtExecutor {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -715,21 +715,15 @@ public class VariableMgr {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user