This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch node_matcher
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 32e384ae679e828ce85ef4139fe9633ed9378bbe
Author: HTHou <[email protected]>
AuthorDate: Tue Jan 26 10:30:18 2021 +0800

    add create timeseries path checker
---
 server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java |  2 ++
 server/src/main/java/org/apache/iotdb/db/metadata/MTree.java   |  9 +++++++++
 .../java/org/apache/iotdb/db/qp/executor/PlanExecutor.java     | 10 ++++++++--
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java 
b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 8ed06b0..eb61cb3 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -63,6 +63,8 @@ public class IoTDBConfig {
 
   public static final Pattern STORAGE_GROUP_PATTERN = 
Pattern.compile(STORAGE_GROUP_MATCHER);
 
+  public static final Pattern NODE_PATTERN = Pattern.compile(NODE_MATCHER);
+  
   /**
    * Port which the metrics service listens to.
    */
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java 
b/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
index c204459..7f81c3f 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
@@ -196,6 +196,7 @@ public class MTree implements Serializable {
     if (nodeNames.length <= 2 || !nodeNames[0].equals(root.getName())) {
       throw new IllegalPathException(path.getFullPath());
     }
+    checkTimeseries(path.getFullPath());
     MNode cur = root;
     boolean hasSetStorageGroup = false;
     // e.g, path = root.sg.d1.s1,  create internal nodes and set cur to d1 node
@@ -237,6 +238,14 @@ public class MTree implements Serializable {
     }
   }
 
+  private void checkTimeseries(String timeseries) throws IllegalPathException {
+    if (!IoTDBConfig.NODE_PATTERN.matcher(timeseries).matches()) {
+      throw new IllegalPathException(String
+          .format("The timeseries name contains unsupported character. %s",
+              timeseries));
+    }
+  }
+
   /**
    * Add an interval path to MTree. This is only used for automatically 
creating schema
    *
diff --git 
a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java 
b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
index ff1ced1..deebba1 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
@@ -1027,7 +1027,8 @@ public class PlanExecutor implements IPlanExecutor {
       throw new PathNotExistException(failedPaths);
     } else {
       throw new StorageEngineException(
-          INSERT_MEASUREMENTS_FAILED_MESSAGE + plan.getFailedMeasurements());
+          INSERT_MEASUREMENTS_FAILED_MESSAGE + plan.getFailedMeasurements() 
+          + (!exceptions.isEmpty() ? (" caused by " + 
exceptions.get(0).getMessage()) : "" ));
     }
   }
 
@@ -1046,6 +1047,9 @@ public class PlanExecutor implements IPlanExecutor {
 
       List<String> notExistedPaths = null;
       List<String> failedMeasurements = null;
+
+      // If there are some exceptions, we assume they caused by the same 
reason.
+      Exception exception = null;
       for (InsertRowPlan plan : insertRowsOfOneDevicePlan.getRowPlans()) {
         if (plan.getFailedMeasurements() != null) {
           if (notExistedPaths == null) {
@@ -1057,6 +1061,7 @@ public class PlanExecutor implements IPlanExecutor {
           List<Exception> exceptions = plan.getFailedExceptions();
           boolean isPathNotExistException = true;
           for (Exception e : exceptions) {
+            exception = e;
             Throwable curException = e;
             while (curException.getCause() != null) {
               curException = curException.getCause();
@@ -1077,7 +1082,8 @@ public class PlanExecutor implements IPlanExecutor {
         throw new PathNotExistException(notExistedPaths);
       } else if (notExistedPaths != null && !failedMeasurements.isEmpty()) {
         throw new StorageEngineException(
-            "failed to insert points " + failedMeasurements);
+            "failed to insert points " + failedMeasurements
+            + (exception != null ? (" caused by " + exception.getMessage()) : 
"" ));
       }
 
     } catch (StorageEngineException | MetadataException e) {

Reply via email to