You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by zy...@apache.org on 2023/02/20 10:01:16 UTC
[iotdb] branch rel/1.0 updated: [To rel/1.0][IOTDB-5548] Fix typo in ASTVisitor.createSchemaTemplate and ASTvisitor.parseIdentifier (#9087)
This is an automated email from the ASF dual-hosted git repository.
zyk pushed a commit to branch rel/1.0
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/1.0 by this push:
new f802b851c9 [To rel/1.0][IOTDB-5548] Fix typo in ASTVisitor.createSchemaTemplate and ASTvisitor.parseIdentifier (#9087)
f802b851c9 is described below
commit f802b851c98dd5d797cfd0cc59e90016cdd95b95
Author: Liao Lanyu <14...@qq.com>
AuthorDate: Mon Feb 20 18:01:10 2023 +0800
[To rel/1.0][IOTDB-5548] Fix typo in ASTVisitor.createSchemaTemplate and ASTvisitor.parseIdentifier (#9087)
---
.../org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java | 10 +++++-----
.../db/service/thrift/impl/ClientRPCServiceImpl.java | 17 +++++++++++++++++
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
index 3732959758..8d2c05ab22 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
@@ -1579,11 +1579,11 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
}
}
- private void checkIdentifier(String src) {
- if (!TsFileConstant.IDENTIFIER_PATTERN.matcher(src).matches()) {
+ private static void checkIdentifier(String src) {
+ if (!TsFileConstant.IDENTIFIER_PATTERN.matcher(src).matches() || PathUtils.isRealNumber(src)) {
throw new SQLParserException(
String.format(
- "%s is illegal, identifier not enclosed with backticks can only consist of digits, characters and underscore.",
+ "%s is illegal, identifier not enclosed with backticks can not be a real number and can only consist of digits, characters and underscore.",
src));
}
}
@@ -1656,7 +1656,7 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
return src;
}
- private String parseIdentifier(String src) {
+ public static String parseIdentifier(String src) {
if (src.startsWith(TsFileConstant.BACK_QUOTE_STRING)
&& src.endsWith(TsFileConstant.BACK_QUOTE_STRING)) {
return src.substring(1, src.length() - 1)
@@ -2591,7 +2591,7 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
@Override
public Statement visitCreateSchemaTemplate(IoTDBSqlParser.CreateSchemaTemplateContext ctx) {
- String name = parseIdentifier(parseIdentifier(ctx.templateName.getText()));
+ String name = parseIdentifier(ctx.templateName.getText());
List<List<String>> measurementsList = new ArrayList<>();
List<List<TSDataType>> dataTypesList = new ArrayList<>();
List<List<TSEncoding>> encodingsList = new ArrayList<>();
diff --git a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/ClientRPCServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/ClientRPCServiceImpl.java
index a52a9e4983..98117e5115 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/ClientRPCServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/ClientRPCServiceImpl.java
@@ -43,6 +43,7 @@ import org.apache.iotdb.db.mpp.plan.analyze.schema.ClusterSchemaFetcher;
import org.apache.iotdb.db.mpp.plan.analyze.schema.ISchemaFetcher;
import org.apache.iotdb.db.mpp.plan.execution.ExecutionResult;
import org.apache.iotdb.db.mpp.plan.execution.IQueryExecution;
+import org.apache.iotdb.db.mpp.plan.parser.ASTVisitor;
import org.apache.iotdb.db.mpp.plan.parser.StatementGenerator;
import org.apache.iotdb.db.mpp.plan.statement.Statement;
import org.apache.iotdb.db.mpp.plan.statement.crud.DeleteDataStatement;
@@ -1412,6 +1413,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
return getNotLoggedInStatus();
}
+ req.setName(checkIdentifierAndRemoveBackQuotesIfNecessary(req.getName()));
+
// Step 1: transfer from TSCreateSchemaTemplateReq to Statement
CreateSchemaTemplateStatement statement = StatementGenerator.createStatement(req);
@@ -1466,6 +1469,11 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
return resp;
}
+ // "" and * have special meaning in implementation. Currently, we do not deal with them.
+ if (!req.getName().equals("") && !req.getName().equals("*")) {
+ req.setName(checkIdentifierAndRemoveBackQuotesIfNecessary(req.getName()));
+ }
+
Statement statement = StatementGenerator.createStatement(req);
if (statement == null) {
resp.setStatus(
@@ -1570,6 +1578,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
return getNotLoggedInStatus();
}
+
+ req.setTemplateName(checkIdentifierAndRemoveBackQuotesIfNecessary(req.getTemplateName()));
// Step 1: transfer from TSCreateSchemaTemplateReq to Statement
SetSchemaTemplateStatement statement = StatementGenerator.createStatement(req);
@@ -1613,6 +1623,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
return getNotLoggedInStatus();
}
+ req.setTemplateName(checkIdentifierAndRemoveBackQuotesIfNecessary(req.getTemplateName()));
// Step 1: transfer from TSCreateSchemaTemplateReq to Statement
@@ -1659,6 +1670,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
return getNotLoggedInStatus();
}
+ req.setTemplateName(checkIdentifierAndRemoveBackQuotesIfNecessary(req.getTemplateName()));
+
// Step 1: transfer from TSCreateSchemaTemplateReq to Statement
DropSchemaTemplateStatement statement = StatementGenerator.createStatement(req);
@@ -1803,6 +1816,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
operation.getName());
}
+ private String checkIdentifierAndRemoveBackQuotesIfNecessary(String identifier) {
+ return identifier == null ? null : ASTVisitor.parseIdentifier(identifier);
+ }
+
@Override
public void handleClientExit() {
IClientSession session = SESSION_MANAGER.getCurrSession();