Caideyipi commented on code in PR #15030:
URL: https://github.com/apache/iotdb/pull/15030#discussion_r1984669535
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/user/BasicUserManager.java:
##########
@@ -177,10 +173,9 @@ public boolean revokeRoleFromUser(String roleName, String
username) throws AuthE
getEntityNotExistErrorCode(),
String.format(getNoSuchEntityError(), username));
}
if (!user.hasRole(roleName)) {
Review Comment:
Can also remove this
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java:
##########
@@ -1443,81 +1443,102 @@ private String stripQuotes(String text) {
return text;
}
+ private String stripDoubleQuotes(String text) {
+ if (text != null && text.length() >= 2 && text.startsWith("\"") &&
text.endsWith("\"")) {
+ return text.substring(1, text.length() - 1).replace("''", "'");
+ }
+ return text;
+ }
+
+ private String stripBackQuotes(String quoted) {
Review Comment:
Do we really need to support this?
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java:
##########
@@ -1443,81 +1443,102 @@ private String stripQuotes(String text) {
return text;
}
+ private String stripDoubleQuotes(String text) {
+ if (text != null && text.length() >= 2 && text.startsWith("\"") &&
text.endsWith("\"")) {
+ return text.substring(1, text.length() - 1).replace("''", "'");
+ }
+ return text;
+ }
+
+ private String stripBackQuotes(String quoted) {
+ return quoted.replaceAll("^`|`$", "");
+ }
+
+ private String handleStripQuotes(RelationalSqlParser.IdentifierContext id) {
+ if (id instanceof RelationalSqlParser.UnquotedIdentifierContext) {
+ return id.getText();
+ } else if (id instanceof RelationalSqlParser.QuotedIdentifierContext) {
+ return stripDoubleQuotes(id.getText());
+ } else if (id instanceof RelationalSqlParser.BackQuotedIdentifierContext) {
+ return stripBackQuotes(id.getText());
+ }
+ throw new SemanticException("IdentifierContext not support");
+ }
+
@Override
public Node
visitCreateUserStatement(RelationalSqlParser.CreateUserStatementContext ctx) {
RelationalAuthorStatement stmt = new
RelationalAuthorStatement(AuthorRType.CREATE_USER);
- stmt.setUserName(ctx.userName.getText());
+ stmt.setUserName(handleStripQuotes(ctx.userName));
Review Comment:
((Identifier)visit(ctx.userName)).getValue()?
--
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]