You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by yu...@apache.org on 2021/07/20 02:56:03 UTC

[iotdb] branch stack-overflow created (now dde60fc)

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

yuyuankang pushed a change to branch stack-overflow
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


      at dde60fc  throw exception

This branch includes the following new commits:

     new dde60fc  throw exception

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[iotdb] 01/01: throw exception

Posted by yu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

yuyuankang pushed a commit to branch stack-overflow
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit dde60fcf92bee8f15347845373957fc6978f26c7
Author: Ring-k <yu...@hotmail.com>
AuthorDate: Tue Jul 20 10:55:15 2021 +0800

    throw exception
---
 .../org/apache/iotdb/db/service/TSServiceImpl.java |  8 +++--
 .../read/expression/util/ExpressionOptimizer.java  | 34 ++++++++++++----------
 2 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index 67f0467..230ae69 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -641,12 +641,12 @@ public class TSServiceImpl implements TSIService.Iface {
 
   @Override
   public TSExecuteStatementResp executeStatement(TSExecuteStatementReq req) {
+    String statement = req.getStatement();
     try {
       if (!checkLogin(req.getSessionId())) {
         return RpcUtils.getTSExecuteStatementResp(TSStatusCode.NOT_LOGIN_ERROR);
       }
 
-      String statement = req.getStatement();
       PhysicalPlan physicalPlan =
           processor.parseSQLToPhysicalPlan(
               statement, sessionIdZoneIdMap.get(req.getSessionId()), req.fetchSize);
@@ -664,9 +664,11 @@ public class TSServiceImpl implements TSIService.Iface {
     } catch (InterruptedException e) {
       LOGGER.error(INFO_INTERRUPT_ERROR, req, e);
       Thread.currentThread().interrupt();
-      return RpcUtils.getTSExecuteStatementResp(onQueryException(e, "executing executeStatement"));
+      return RpcUtils.getTSExecuteStatementResp(
+          onQueryException(e, "executing \"" + statement + "\""));
     } catch (Exception e) {
-      return RpcUtils.getTSExecuteStatementResp(onQueryException(e, "executing executeStatement"));
+      return RpcUtils.getTSExecuteStatementResp(
+          onQueryException(e, "executing \"" + statement + "\""));
     }
   }
 
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/expression/util/ExpressionOptimizer.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/expression/util/ExpressionOptimizer.java
index ea2a24f..b056286 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/expression/util/ExpressionOptimizer.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/expression/util/ExpressionOptimizer.java
@@ -70,21 +70,25 @@ public class ExpressionOptimizer {
             (GlobalTimeExpression) right, left, selectedSeries, relation);
       } else if (left.getType() != ExpressionType.GLOBAL_TIME
           && right.getType() != ExpressionType.GLOBAL_TIME) {
-        IExpression regularLeft = optimize(left, selectedSeries);
-        IExpression regularRight = optimize(right, selectedSeries);
-        IBinaryExpression midRet = null;
-        if (relation == ExpressionType.AND) {
-          midRet = BinaryExpression.and(regularLeft, regularRight);
-        } else if (relation == ExpressionType.OR) {
-          midRet = BinaryExpression.or(regularLeft, regularRight);
-        } else {
-          throw new UnsupportedOperationException("unsupported IExpression type: " + relation);
-        }
-        if (midRet.getLeft().getType() == ExpressionType.GLOBAL_TIME
-            || midRet.getRight().getType() == ExpressionType.GLOBAL_TIME) {
-          return optimize(midRet, selectedSeries);
-        } else {
-          return midRet;
+        try {
+          IExpression regularLeft = optimize(left, selectedSeries);
+          IExpression regularRight = optimize(right, selectedSeries);
+          IBinaryExpression midRet = null;
+          if (relation == ExpressionType.AND) {
+            midRet = BinaryExpression.and(regularLeft, regularRight);
+          } else if (relation == ExpressionType.OR) {
+            midRet = BinaryExpression.or(regularLeft, regularRight);
+          } else {
+            throw new UnsupportedOperationException("unsupported IExpression type: " + relation);
+          }
+          if (midRet.getLeft().getType() == ExpressionType.GLOBAL_TIME
+              || midRet.getRight().getType() == ExpressionType.GLOBAL_TIME) {
+            return optimize(midRet, selectedSeries);
+          } else {
+            return midRet;
+          }
+        } catch (StackOverflowError stackOverflowError) {
+          throw new QueryFilterOptimizationException("StackOverflowError is encountered.");
         }
       }
     }