morrySnow commented on code in PR #41913: URL: https://github.com/apache/doris/pull/41913#discussion_r1818722017
########## fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4: ########## @@ -820,7 +820,7 @@ optionWithoutType | NAMES (charsetName=identifierOrText | DEFAULT) (COLLATE collateName=identifierOrText | DEFAULT)? #setCollate | PASSWORD (FOR userIdentify)? EQ (STRING_LITERAL - | (PASSWORD LEFT_PAREN STRING_LITERAL RIGHT_PAREN)) #setPassword + | (isPlain=PASSWORD LEFT_PAREN STRING_LITERAL RIGHT_PAREN)) #setPassword Review Comment: maybe should be `isNotPlain` ? ########## fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java: ########## @@ -3829,4 +3855,111 @@ public LogicalPlan visitShowConfig(ShowConfigContext ctx) { } return command; } + + @Override + public SetOptionsCommand visitSetOptions(SetOptionsContext ctx) { + List<SetVarOp> setVarOpList = new ArrayList<>(1); + for (Object child : ctx.children) { + if (child instanceof RuleNode) { + setVarOpList.add(typedVisit((RuleNode) child)); + } + } + return new SetOptionsCommand(setVarOpList); + } + + @Override + public SetVarOp visitSetSystemVariable(SetSystemVariableContext ctx) { + SetType type = SetType.DEFAULT; + if (ctx.GLOBAL() != null) { + type = SetType.GLOBAL; + } else if (ctx.LOCAL() != null || ctx.SESSION() != null) { + type = SetType.SESSION; + } + String name = stripQuotes(ctx.identifier().getText()); + Expression expression = ctx.expression() != null ? typedVisit(ctx.expression()) : null; + return new SetSessionVarOp(type, name, expression); + } + + @Override + public SetVarOp visitSetVariableWithType(SetVariableWithTypeContext ctx) { + SetType type = SetType.DEFAULT; + if (ctx.GLOBAL() != null) { + type = SetType.GLOBAL; + } else if (ctx.LOCAL() != null || ctx.SESSION() != null) { + type = SetType.SESSION; + } + String name = stripQuotes(ctx.identifier().getText()); + Expression expression = ctx.expression() != null ? typedVisit(ctx.expression()) : null; + return new SetSessionVarOp(type, name, expression); + } + + @Override + public SetVarOp visitSetPassword(SetPasswordContext ctx) { + String user; + String host; + boolean isDomain; + String passwordText; + UserIdentity userIdentity = null; + if (ctx.userIdentify() != null) { + user = stripQuotes(ctx.userIdentify().user.getText()); + host = ctx.userIdentify().host != null ? stripQuotes(ctx.userIdentify().host.getText()) : "%"; + isDomain = ctx.userIdentify().ATSIGN() != null; + userIdentity = new UserIdentity(user, host, isDomain); + } + passwordText = stripQuotes(ctx.STRING_LITERAL().getText()); + return new SetPassVarOp(userIdentity, new PassVar(passwordText, ctx.isPlain != null)); Review Comment: ```suggestion return new SetPassVarOp(userIdentity, new PassVar(passwordText, ctx.isNotPlain == null)); ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java: ########## @@ -3829,4 +3855,111 @@ public LogicalPlan visitShowConfig(ShowConfigContext ctx) { } return command; } + + @Override + public SetOptionsCommand visitSetOptions(SetOptionsContext ctx) { + List<SetVarOp> setVarOpList = new ArrayList<>(1); + for (Object child : ctx.children) { + if (child instanceof RuleNode) { + setVarOpList.add(typedVisit((RuleNode) child)); + } + } + return new SetOptionsCommand(setVarOpList); + } + + @Override + public SetVarOp visitSetSystemVariable(SetSystemVariableContext ctx) { + SetType type = SetType.DEFAULT; + if (ctx.GLOBAL() != null) { + type = SetType.GLOBAL; + } else if (ctx.LOCAL() != null || ctx.SESSION() != null) { + type = SetType.SESSION; + } + String name = stripQuotes(ctx.identifier().getText()); + Expression expression = ctx.expression() != null ? typedVisit(ctx.expression()) : null; + return new SetSessionVarOp(type, name, expression); + } + + @Override + public SetVarOp visitSetVariableWithType(SetVariableWithTypeContext ctx) { + SetType type = SetType.DEFAULT; + if (ctx.GLOBAL() != null) { + type = SetType.GLOBAL; + } else if (ctx.LOCAL() != null || ctx.SESSION() != null) { + type = SetType.SESSION; + } + String name = stripQuotes(ctx.identifier().getText()); + Expression expression = ctx.expression() != null ? typedVisit(ctx.expression()) : null; + return new SetSessionVarOp(type, name, expression); + } + + @Override + public SetVarOp visitSetPassword(SetPasswordContext ctx) { + String user; + String host; + boolean isDomain; + String passwordText; + UserIdentity userIdentity = null; + if (ctx.userIdentify() != null) { + user = stripQuotes(ctx.userIdentify().user.getText()); + host = ctx.userIdentify().host != null ? stripQuotes(ctx.userIdentify().host.getText()) : "%"; + isDomain = ctx.userIdentify().ATSIGN() != null; + userIdentity = new UserIdentity(user, host, isDomain); + } + passwordText = stripQuotes(ctx.STRING_LITERAL().getText()); + return new SetPassVarOp(userIdentity, new PassVar(passwordText, ctx.isPlain != null)); + } + + @Override + public SetVarOp visitSetNames(SetNamesContext ctx) { + return new SetNamesVarOp(); + } + + @Override + public SetVarOp visitSetCharset(SetCharsetContext ctx) { + String charset = ctx.charsetName != null ? stripQuotes(ctx.charsetName.getText()) : null; + return new SetCharsetAndCollateVarOp(charset); + } + + @Override + public SetVarOp visitSetCollate(SetCollateContext ctx) { + String charset = ctx.charsetName != null ? stripQuotes(ctx.charsetName.getText()) : null; + String collate = ctx.collateName != null ? stripQuotes(ctx.collateName.getText()) : null; + return new SetCharsetAndCollateVarOp(charset, collate); + } + + @Override + public SetVarOp visitSetLdapAdminPassword(SetLdapAdminPasswordContext ctx) { + String passwordText = stripQuotes(ctx.STRING_LITERAL().getText()); + boolean isPlain = ctx.PASSWORD() != null; Review Comment: ```suggestion boolean isPlain = ctx.PASSWORD() == null; ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org