You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2021/06/08 10:28:47 UTC
[shardingsphere] branch master updated: fix create user password
parse error (#10713)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new a87367f fix create user password parse error (#10713)
a87367f is described below
commit a87367f5e4e2e1d1900166ad4cb9edd11c85d710
Author: Zhengqiang Duan <st...@gmail.com>
AuthorDate: Tue Jun 8 18:28:08 2021 +0800
fix create user password parse error (#10713)
* fix create user password parse error
* modify visit class
---
.../statement/impl/MySQLDCLStatementSQLVisitor.java | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDCLStatementSQLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDCLStatementSQLVisitor.java
index f7c9827..637bbaa 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDCLStatementSQLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDCLStatementSQLVisitor.java
@@ -86,6 +86,7 @@ import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.StaticP
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.StaticPrivilegeTriggerContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.StaticPrivilegeUpdateContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.StaticPrivilegeUsageContext;
+import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.String_Context;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.TlsOptionContext;
import org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser.UserNameContext;
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.ACLTypeEnum;
@@ -93,6 +94,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.GrantLeve
import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.PrivilegeTypeEnum;
import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.NumberLiteralValue;
+import org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dcl.MySQLAlterUserStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dcl.MySQLCreateRoleStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dcl.MySQLCreateUserStatement;
@@ -555,7 +557,7 @@ public final class MySQLDCLStatementSQLVisitor extends MySQLStatementSQLVisitor
result.setStartIndex(ctx.start.getStartIndex());
result.setStopIndex(ctx.stop.getStopIndex());
if (null != ctx.string_()) {
- result.setAuth(ctx.string_().getText());
+ result.setAuth(((StringLiteralValue) visit(ctx.string_())).getValue());
result.setHasPasswordGenerator(false);
result.setUsesIdentifiedByClause(true);
result.setDiscardOldPassword(false);
@@ -570,6 +572,11 @@ public final class MySQLDCLStatementSQLVisitor extends MySQLStatementSQLVisitor
}
@Override
+ public ASTNode visitString_(final String_Context ctx) {
+ return new StringLiteralValue(ctx.getText());
+ }
+
+ @Override
public ASTNode visitCreateUserEntryIdentifiedWith(final CreateUserEntryIdentifiedWithContext ctx) {
UserSegment result = (UserSegment) visit(ctx.userName());
result.setStartIndex(ctx.start.getStartIndex());
@@ -582,14 +589,14 @@ public final class MySQLDCLStatementSQLVisitor extends MySQLStatementSQLVisitor
result.setRetainCurrentPassword(false);
} else if (null != ctx.AS()) {
result.setPlugin(ctx.textOrIdentifier().getText());
- result.setAuth(ctx.string_().getText());
+ result.setAuth(((StringLiteralValue) visit(ctx.string_())).getValue());
result.setHasPasswordGenerator(false);
result.setUsesIdentifiedByClause(true);
result.setDiscardOldPassword(false);
result.setRetainCurrentPassword(false);
} else if (null != ctx.BY() && null != ctx.string_()) {
result.setPlugin(ctx.textOrIdentifier().getText());
- result.setAuth(ctx.string_().getText());
+ result.setAuth(((StringLiteralValue) visit(ctx.string_())).getValue());
result.setHasPasswordGenerator(false);
result.setUsesIdentifiedByClause(true);
result.setUsesIdentifiedWithClause(true);
@@ -597,7 +604,7 @@ public final class MySQLDCLStatementSQLVisitor extends MySQLStatementSQLVisitor
result.setRetainCurrentPassword(false);
} else {
result.setPlugin(ctx.textOrIdentifier().getText());
- result.setAuth(ctx.string_().getText());
+ result.setAuth(((StringLiteralValue) visit(ctx.string_())).getValue());
result.setHasPasswordGenerator(true);
result.setUsesIdentifiedByClause(true);
result.setUsesIdentifiedWithClause(true);