[fix](session-variable) fix set global var on non-master FE return error (#20179)

This commit is contained in:
Mingyu Chen
2023-05-30 16:26:28 +08:00
committed by GitHub
parent 49ce4e6fda
commit 3735c21ef9

View File

@ -243,15 +243,18 @@ public class VariableMgr {
}
// Check if this setVar can be set correctly
// Do not use ErrorReport.reportDdlException to throw exeception, it will set the query state in connection context.
// But in some case, we do not want to set the query state and need to ignore that error.
// Set setVarForNonMasterFE() is an example.
private static void checkUpdate(SetVar setVar, int flag) throws DdlException {
if ((flag & READ_ONLY) != 0) {
ErrorReport.reportDdlException(ErrorCode.ERR_VARIABLE_IS_READONLY, setVar.getVariable());
throw new DdlException(ErrorCode.ERR_VARIABLE_IS_READONLY.formatErrorMsg(setVar.getVariable()));
}
if (setVar.getType() == SetType.GLOBAL && (flag & SESSION_ONLY) != 0) {
ErrorReport.reportDdlException(ErrorCode.ERR_LOCAL_VARIABLE, setVar.getVariable());
throw new DdlException(ErrorCode.ERR_GLOBAL_VARIABLE.formatErrorMsg(setVar.getVariable()));
}
if (setVar.getType() != SetType.GLOBAL && (flag & GLOBAL) != 0) {
ErrorReport.reportDdlException(ErrorCode.ERR_GLOBAL_VARIABLE, setVar.getVariable());
throw new DdlException(ErrorCode.ERR_GLOBAL_VARIABLE.formatErrorMsg(setVar.getVariable()));
}
}