You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2021/09/10 09:37:44 UTC

[iotdb] branch rel/0.12 updated: [To rel/0.12] cherry-pick two CLI bug fix PRs (#3944)

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

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


The following commit(s) were added to refs/heads/rel/0.12 by this push:
     new 489a51c  [To rel/0.12] cherry-pick two CLI bug fix PRs (#3944)
489a51c is described below

commit 489a51c486c46d2d32bc2bc10dfc35f9394f8aae
Author: Haonan <hh...@outlook.com>
AuthorDate: Fri Sep 10 17:37:17 2021 +0800

    [To rel/0.12] cherry-pick two CLI bug fix PRs (#3944)
    
    * [IOTDB-1275] Fix backgroup exec for cli -e function causes an infinite loop in writing output file (#3932)
    
    * [IOTDB-1659] Fix Windows CLI cannot set maxPRC less than or equal to 0 (#3936)
---
 .../java/org/apache/iotdb/cli/AbstractCli.java     |  3 +++
 cli/src/main/java/org/apache/iotdb/cli/Cli.java    |  2 +-
 cli/src/main/java/org/apache/iotdb/cli/WinCli.java | 12 ++++------
 .../org/apache/iotdb/cli/StartClientScriptIT.java  | 27 ++++++++++++++++++++++
 4 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java b/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
index 55216b9..467c234 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
@@ -288,6 +288,9 @@ public abstract class AbstractCli {
 
       execute = executeCommand.toString();
       hasExecuteSQL = true;
+      // When execute sql in CLI with -e mode, we should print all results by setting continuePrint
+      // is true.
+      continuePrint = true;
       args = Arrays.copyOfRange(args, 0, index);
       return args;
     }
diff --git a/cli/src/main/java/org/apache/iotdb/cli/Cli.java b/cli/src/main/java/org/apache/iotdb/cli/Cli.java
index 0889735..6e57d27 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/Cli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/Cli.java
@@ -102,7 +102,7 @@ public class Cli extends AbstractCli {
     } catch (NumberFormatException e) {
       println(
           IOTDB_CLI_PREFIX
-              + "> error format of max print row count, it should be a number and greater than 0");
+              + "> error format of max print row count, it should be an integer number");
       return false;
     }
     return true;
diff --git a/cli/src/main/java/org/apache/iotdb/cli/WinCli.java b/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
index 34f44f7..7d9e938 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/WinCli.java
@@ -99,20 +99,16 @@ public class WinCli extends AbstractCli {
         timeFormat = RpcUtils.setTimeFormat("long");
       }
       if (commandLine.hasOption(MAX_PRINT_ROW_COUNT_ARGS)) {
-        maxPrintRowCount = Integer.parseInt(commandLine.getOptionValue(MAX_PRINT_ROW_COUNT_ARGS));
-        if (maxPrintRowCount <= 0) {
-          println(
-              IOTDB_CLI_PREFIX
-                  + "> error format of max print row count, it should be a number greater than 0");
-          return false;
-        }
+        setMaxDisplayNumber(commandLine.getOptionValue(MAX_PRINT_ROW_COUNT_ARGS));
       }
     } catch (ParseException e) {
       println("Require more params input, please check the following hint.");
       hf.printHelp(IOTDB_CLI_PREFIX, options, true);
       return false;
     } catch (NumberFormatException e) {
-      println(IOTDB_CLI_PREFIX + "> error format of max print row count, it should be a number");
+      println(
+          IOTDB_CLI_PREFIX
+              + "> error format of max print row count, it should be an integer number");
       return false;
     }
     return true;
diff --git a/cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java b/cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java
index 829cd9a..7fa89bb 100644
--- a/cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java
+++ b/cli/src/test/java/org/apache/iotdb/cli/StartClientScriptIT.java
@@ -75,9 +75,23 @@ public class StartClientScriptIT extends AbstractScript {
             "cmd.exe",
             "/c",
             dir + File.separator + "sbin" + File.separator + "start-cli.bat",
+            "-maxPRC",
+            "0",
             "-e",
             "\"flush\"");
     testOutput(builder2, output2);
+
+    final String[] output3 = {
+      "IoTDB> error format of max print row count, it should be an integer number"
+    };
+    ProcessBuilder builder3 =
+        new ProcessBuilder(
+            "cmd.exe",
+            "/c",
+            dir + File.separator + "sbin" + File.separator + "start-cli.bat",
+            "-maxPRC",
+            "-1111111111111111111111111111");
+    testOutput(builder3, output3);
   }
 
   @Override
@@ -105,8 +119,21 @@ public class StartClientScriptIT extends AbstractScript {
         new ProcessBuilder(
             "sh",
             dir + File.separator + "sbin" + File.separator + "start-cli.sh",
+            "-maxPRC",
+            "0",
             "-e",
             "\"flush\"");
     testOutput(builder2, output2);
+
+    final String[] output3 = {
+      "IoTDB> error format of max print row count, it should be an integer number"
+    };
+    ProcessBuilder builder3 =
+        new ProcessBuilder(
+            "sh",
+            dir + File.separator + "sbin" + File.separator + "start-cli.sh",
+            "-maxPRC",
+            "-1111111111111111111111111111");
+    testOutput(builder3, output3);
   }
 }