From 5f8baf6ed1660b70cc65be90261d5bacf7070c77 Mon Sep 17 00:00:00 2001 From: Bob Liu Date: Thu, 9 Nov 2023 14:36:23 +0800 Subject: [PATCH 1/7] fix shellRunSingleCommandImp --- tools/shell/src/shellEngine.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 3b150230e7..5ccbc8d2ab 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -199,22 +199,12 @@ void shellRunSingleCommandImp(char *command) { bool printMode = false; if ((sptr = strstr(command, ">>")) != NULL) { - cptr = strstr(command, ";"); - if (cptr != NULL) { - *cptr = '\0'; - } - fname = sptr + 2; while (*fname == ' ') fname++; *sptr = '\0'; } if ((sptr = strstr(command, "\\G")) != NULL) { - cptr = strstr(command, ";"); - if (cptr != NULL) { - *cptr = '\0'; - } - *sptr = '\0'; printMode = true; // When output to a file, the switch does not work. } From dbb271507eb23042c5bf0aea647005f29981c6ca Mon Sep 17 00:00:00 2001 From: Bob Liu Date: Thu, 9 Nov 2023 20:48:01 +0800 Subject: [PATCH 2/7] add query test case for separator '\G', ';' --- tests/parallel_test/cases.task | 1 + tests/script/tsim/query/separator.sim | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 tests/script/tsim/query/separator.sim diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 28aa8744fd..d405d7ae12 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -1062,6 +1062,7 @@ e ,,y,script,./test.sh -f tsim/query/bug3398.sim ,,y,script,./test.sh -f tsim/query/explain_tsorder.sim ,,y,script,./test.sh -f tsim/query/apercentile.sim +,,y,script,./test.sh -f tsim/query/separator.sim ,,y,script,./test.sh -f tsim/qnode/basic1.sim ,,y,script,./test.sh -f tsim/snode/basic1.sim ,,y,script,./test.sh -f tsim/mnode/basic1.sim diff --git a/tests/script/tsim/query/separator.sim b/tests/script/tsim/query/separator.sim new file mode 100644 index 0000000000..c2f6372e15 --- /dev/null +++ b/tests/script/tsim/query/separator.sim @@ -0,0 +1,11 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql select 'a;b' as x\G +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From 9f4f3406227ad23ca46c1a924b6fad9b280c956a Mon Sep 17 00:00:00 2001 From: Bob Liu Date: Fri, 10 Nov 2023 14:21:41 +0800 Subject: [PATCH 3/7] fix case; adjust sqlstr --- tests/script/tsim/query/separator.sim | 2 +- tools/shell/src/shellEngine.c | 5 +++++ tools/shell/src/shellWebsocket.c | 11 +++-------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/script/tsim/query/separator.sim b/tests/script/tsim/query/separator.sim index c2f6372e15..a49ac6312a 100644 --- a/tests/script/tsim/query/separator.sim +++ b/tests/script/tsim/query/separator.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect -sql select 'a;b' as x\G +sql select 'a;b' as x if $rows != 1 then return -1 endi diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 5ccbc8d2ab..8926d21534 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -202,6 +202,11 @@ void shellRunSingleCommandImp(char *command) { fname = sptr + 2; while (*fname == ' ') fname++; *sptr = '\0'; + + cptr = strstr(fname, ";"); + if (cptr != NULL) { + *cptr = '\0'; + } } if ((sptr = strstr(command, "\\G")) != NULL) { diff --git a/tools/shell/src/shellWebsocket.c b/tools/shell/src/shellWebsocket.c index e83ceff099..fceec37a64 100644 --- a/tools/shell/src/shellWebsocket.c +++ b/tools/shell/src/shellWebsocket.c @@ -236,22 +236,17 @@ void shellRunSingleCommandWebsocketImp(char *command) { bool printMode = false; if ((sptr = strstr(command, ">>")) != NULL) { - cptr = strstr(command, ";"); - if (cptr != NULL) { - *cptr = '\0'; - } - fname = sptr + 2; while (*fname == ' ') fname++; *sptr = '\0'; - } - if ((sptr = strstr(command, "\\G")) != NULL) { - cptr = strstr(command, ";"); + cptr = strstr(fname, ";"); if (cptr != NULL) { *cptr = '\0'; } + } + if ((sptr = strstr(command, "\\G")) != NULL) { *sptr = '\0'; printMode = true; // When output to a file, the switch does not work. } From 05eb328b2214fd0e9a042d840dadf02fd36a28b8 Mon Sep 17 00:00:00 2001 From: Bob Liu Date: Mon, 13 Nov 2023 15:20:35 +0800 Subject: [PATCH 4/7] add test case for \G, >> in sql, excute in shell --- tests/parallel_test/cases.task | 1 + tests/system-test/2-query/ts-4233.py | 46 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/system-test/2-query/ts-4233.py diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index d405d7ae12..97df3a8347 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -840,6 +840,7 @@ e ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/projectionDesc.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/odbc.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts-4233.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/fill_with_group.py ,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-20582.py diff --git a/tests/system-test/2-query/ts-4233.py b/tests/system-test/2-query/ts-4233.py new file mode 100644 index 0000000000..9b0a2f175c --- /dev/null +++ b/tests/system-test/2-query/ts-4233.py @@ -0,0 +1,46 @@ + +import taos + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), True) + + def checksql(self, sql): + result = os.popen("taos -s '%s'" %sql) + res = result.read() + print(res) + if ("Query OK" in res): + tdLog.info(f"checkEqual success") + else : + tdLog.exit(f"checkEqual error") + + def check(self): + conn = taos.connect() + sql = "select 'a;b' as x" + tdSql.query(f"%s" %sql) + tdSql.checkRows(1) + + self.checksql('select "a;b" as x\G') + self.checksql('select "a;b" as x >> /tmp/res.txt') + return + + def run(self): + tdSql.prepare() + self.check() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) From fbd0d6a3ccbcfec6ecbc6dfd344c3eb259987fd7 Mon Sep 17 00:00:00 2001 From: Bob Liu Date: Mon, 13 Nov 2023 15:43:07 +0800 Subject: [PATCH 5/7] cancel task --- tests/parallel_test/cases.task | 1 - tests/script/tsim/query/separator.sim | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 97df3a8347..c89700ba78 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -1063,7 +1063,6 @@ e ,,y,script,./test.sh -f tsim/query/bug3398.sim ,,y,script,./test.sh -f tsim/query/explain_tsorder.sim ,,y,script,./test.sh -f tsim/query/apercentile.sim -,,y,script,./test.sh -f tsim/query/separator.sim ,,y,script,./test.sh -f tsim/qnode/basic1.sim ,,y,script,./test.sh -f tsim/snode/basic1.sim ,,y,script,./test.sh -f tsim/mnode/basic1.sim diff --git a/tests/script/tsim/query/separator.sim b/tests/script/tsim/query/separator.sim index a49ac6312a..06e9b89b9c 100644 --- a/tests/script/tsim/query/separator.sim +++ b/tests/script/tsim/query/separator.sim @@ -3,9 +3,9 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect -sql select 'a;b' as x -if $rows != 1 then - return -1 -endi +system taos -P7100 -s 'select "a;b" as x\G' | grep -v 'Query OK' | grep -v 'Client Version' > /tmp/separator.result +system echo ----------------------diff start----------------------- +system git diff --exit-code --color tsim/query/r/separator.result /tmp/separator.result +system echo ----------------------diff succeed----------------------- system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From c4ac65557f0f559e7791bfc7032875ee5ef3cd2a Mon Sep 17 00:00:00 2001 From: Bob Liu Date: Mon, 13 Nov 2023 16:30:12 +0800 Subject: [PATCH 6/7] adjust case --- tests/parallel_test/cases.task | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index c89700ba78..45721a2b65 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -119,6 +119,10 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/slimit.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts-4233.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts-4233.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts-4233.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts-4233.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 3-enterprise/restore/restoreDnode.py -N 5 -M 3 -i False ,,y,system-test,./pytest.sh python3 ./test.py -f 3-enterprise/restore/restoreVnode.py -N 5 -M 3 -i False @@ -840,7 +844,6 @@ e ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/projectionDesc.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/odbc.py -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts-4233.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/fill_with_group.py ,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-20582.py From 6a303b09a5a1cc0c43680d4b7c4d8bbb46f41e4f Mon Sep 17 00:00:00 2001 From: dapan1121 <72057773+dapan1121@users.noreply.github.com> Date: Tue, 14 Nov 2023 13:48:48 +0800 Subject: [PATCH 7/7] Delete tests/script/tsim/query/separator.sim --- tests/script/tsim/query/separator.sim | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 tests/script/tsim/query/separator.sim diff --git a/tests/script/tsim/query/separator.sim b/tests/script/tsim/query/separator.sim deleted file mode 100644 index 06e9b89b9c..0000000000 --- a/tests/script/tsim/query/separator.sim +++ /dev/null @@ -1,11 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/exec.sh -n dnode1 -s start -sql connect - -system taos -P7100 -s 'select "a;b" as x\G' | grep -v 'Query OK' | grep -v 'Client Version' > /tmp/separator.result -system echo ----------------------diff start----------------------- -system git diff --exit-code --color tsim/query/r/separator.result /tmp/separator.result -system echo ----------------------diff succeed----------------------- - -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file