starocean999 commented on code in PR #47554:
URL: https://github.com/apache/doris/pull/47554#discussion_r1948347017
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java:
##########
@@ -5511,5 +5516,116 @@ public LogicalPlan
visitDropDatabase(DropDatabaseContext ctx) {
DropDatabaseInfo databaseInfo = new DropDatabaseInfo(ifExists,
databaseNameParts, force);
return new DropDatabaseCommand(databaseInfo);
}
+
+ @Override
+ public PasswordOptions
visitPasswordOption(DorisParser.PasswordOptionContext ctx) {
+ int historyPolicy = -2;
+ long expirePolicySecond = -2;
+ int reusePolicy = -2;
+ int loginAttempts = -2;
+ long passwordLockSecond = -2;
+ int accountUnlocked = -2;
+
+ if (ctx.historyDefault != null) {
+ historyPolicy = -1;
+ } else if (ctx.historyValue != null) {
+ historyPolicy = Integer.parseInt(ctx.historyValue.getText());
+ }
+
+ if (ctx.expireDefault != null) {
+ expirePolicySecond = -1;
+ } else if (ctx.expireNever != null) {
+ expirePolicySecond = 0;
+ } else if (ctx.expireValue != null) {
+ long value = Long.parseLong(ctx.expireValue.getText());
+ expirePolicySecond = getSecond(value,
ctx.expireTimeUnit.getText());
+ }
+
+ if (ctx.reuseValue != null) {
+ reusePolicy = Integer.parseInt(ctx.reuseValue.getText());
+ }
+
+ if (ctx.attemptsValue != null) {
+ loginAttempts = Integer.parseInt(ctx.attemptsValue.getText());
+ }
+
+ if (ctx.lockUnbounded != null) {
+ passwordLockSecond = -1;
+ } else if (ctx.lockValue != null) {
+ long value = Long.parseLong(ctx.lockValue.getText());
+ passwordLockSecond = getSecond(value, ctx.lockTimeUint.getText());
+ }
+
+ if (ctx.ACCOUNT_LOCK() != null) {
+ accountUnlocked = -1;
+ } else if (ctx.ACCOUNT_UNLOCK() != null) {
+ accountUnlocked = 1;
+ }
+
+ if (expirePolicySecond == -2 && historyPolicy == -2 && reusePolicy ==
-2
+ && loginAttempts == -2 && passwordLockSecond == -2 &&
accountUnlocked == -2) {
+ return PasswordOptions.UNSET_OPTION;
+ }
+
+ return new PasswordOptions(expirePolicySecond,
+ historyPolicy,
+ reusePolicy,
+ loginAttempts,
+ passwordLockSecond,
+ accountUnlocked);
+ }
+
+ private long getSecond(long value, String s) {
+ long ans = 0;
+
+ switch (s) {
+ case "DAY":
+ ans = value * 24 * 60 * 60;
+ break;
+ case "HOUR":
+ ans = value * 60 * 60;
+ break;
+ default:
+ ans = value;
+ }
+ return ans;
+ }
+
+ @Override
+ public LogicalPlan visitCreateUser(CreateUserContext ctx) {
+ String comment = "";
+ if (ctx.COMMENT() != null) {
+ comment = stripQuotes(ctx.STRING_LITERAL(0).getText());
+ }
+
+ PasswordOptions passwordOptions = passwordOptions = (PasswordOptions)
ctx.passwordOption().accept(this);
+
+ UserDesc userDesc = userDesc = (UserDesc)
ctx.grantUserIdentify().accept(this);
+
+ String role = null;
+ if (ctx.role != null) {
+ role = stripQuotes(ctx.role.getText());
+ }
+
+ CreateUserInfo userInfo = new CreateUserInfo(ctx.IF() != null,
+ userDesc,
+ role,
+ passwordOptions,
+ comment);
+
+ return new CreateUserCommand(userInfo);
+ }
+
+ @Override
+ public UserDesc
visitGrantUserIdentify(DorisParser.GrantUserIdentifyContext ctx) {
+ UserIdentity userIdentity = (UserIdentity)
ctx.userIdentify().accept(this);
+
+ String password = "";
+ if (ctx.IDENTIFIED() != null) {
+ password = stripQuotes(ctx.STRING_LITERAL().getText());
+ }
+
+ return new UserDesc(userIdentity, new PassVar(password, true));
Review Comment:
hashed password is missing. You can take old planner as reference:
```
grant_user ::=
user_identity:user_id
{:
/* No password */
RESULT = new UserDesc(user_id);
:}
| user_identity:user_id KW_IDENTIFIED KW_BY STRING_LITERAL:password
{:
/* plain text password */
RESULT = new UserDesc(user_id, new PassVar(password, true));
:}
| user_identity:user_id KW_IDENTIFIED KW_BY KW_PASSWORD
STRING_LITERAL:password
{:
/* hashed password */
RESULT = new UserDesc(user_id, new PassVar(password, false));
:}
;
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]