From 2d9b5ed4f600c2f7cf5efd8dcf1af7f25c37fde5 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Sat, 25 Feb 2023 16:04:21 +0800 Subject: [PATCH] fix: tag like filter issue --- Jenkinsfile2 | 2 +- source/util/src/tutil.c | 2 +- source/util/test/utilTests.cpp | 6 +++- tests/parallel_test/cases.task | 1 + tests/script/tsim/query/tagLikeFilter.sim | 36 +++++++++++++++++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 tests/script/tsim/query/tagLikeFilter.sim diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 9c28489a39..99058b7257 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -387,7 +387,7 @@ pipeline { } steps { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - timeout(time: 75, unit: 'MINUTES'){ + timeout(time: 86, unit: 'MINUTES'){ pre_test_win() pre_test_build_win() run_win_ctest() diff --git a/source/util/src/tutil.c b/source/util/src/tutil.c index 1f9ca7407e..6d95660103 100644 --- a/source/util/src/tutil.c +++ b/source/util/src/tutil.c @@ -468,7 +468,7 @@ size_t tstrncspn(const char *str, size_t size, const char *reject, size_t rsize) c3 = p[s[j + 3]]; if ((c0 | c1 | c2 | c3) != 0) { - size_t count = ((i + 1) >> 2); + size_t count = i * 4; return (c0 | c1) != 0 ? count - c0 + 1 : count - c2 + 3; } } diff --git a/source/util/test/utilTests.cpp b/source/util/test/utilTests.cpp index a355125410..ff1d91aa9d 100644 --- a/source/util/test/utilTests.cpp +++ b/source/util/test/utilTests.cpp @@ -294,6 +294,10 @@ TEST(utilTest, tstrncspn) { const char* reject5 = "911"; v = tstrncspn(p2, strlen(p2), reject5, 0); ASSERT_EQ(v, 14); + + const char* reject6 = "Kk"; + v = tstrncspn(p2, strlen(p2), reject6, 2); + ASSERT_EQ(v, 10); } TEST(utilTest, intToHextStr) { @@ -322,4 +326,4 @@ TEST(utilTest, intToHextStr) { sprintf(destBuf, "%" PRIx64, v); ASSERT_STREQ(buf, destBuf); } -} \ No newline at end of file +} diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index a24efeac5f..2fd1d02de1 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -168,6 +168,7 @@ ,,y,script,./test.sh -f tsim/parser/union.sim ,,y,script,./test.sh -f tsim/parser/union_sysinfo.sim ,,y,script,./test.sh -f tsim/parser/where.sim +,,y,script,./test.sh -f tsim/query/tagLikeFilter.sim ,,y,script,./test.sh -f tsim/query/charScalarFunction.sim ,,y,script,./test.sh -f tsim/query/explain.sim ,,y,script,./test.sh -f tsim/query/interval-offset.sim diff --git a/tests/script/tsim/query/tagLikeFilter.sim b/tests/script/tsim/query/tagLikeFilter.sim new file mode 100644 index 0000000000..79c1bc7c0b --- /dev/null +++ b/tests/script/tsim/query/tagLikeFilter.sim @@ -0,0 +1,36 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql drop database if exists db1; +sql create database if not exists db1 vgroups 10; +sql use db1; +sql create stable sta (ts timestamp, f1 double, f2 binary(200)) tags(t1 binary(100)); +sql create table tba1 using sta tags('ZQMPvstuzZVzCRjFTQawILuGSqZKSqlJwcBtZMxrAEqBbzChHWVDMiAZJwESzJAf'); +sql create table tba2 using sta tags('ieofwehughkreghughuerugu34jf9340aieefjalie28ffj8fj8fafjaekdfjfii'); +sql create table tba3 using sta tags('ZQMPvstuzZVzCRjFTQawILuGSqabSqlJwcBtZMxrAEqBbzChHWVDMiAZJwESzJAf'); +sql insert into tba1 values ('2022-04-26 15:15:01', 1.0, "a"); +sql insert into tba2 values ('2022-04-26 15:15:01', 1.0, "a"); +sql insert into tba2 values ('2022-04-26 15:15:02', 1.0, "a"); +sql insert into tba3 values ('2022-04-26 15:15:01', 1.0, "a"); +sql insert into tba3 values ('2022-04-26 15:15:02', 1.0, "a"); +sql insert into tba3 values ('2022-04-26 15:15:03', 1.0, "a"); +sql select t1 from sta where t1 like '%ab%'; +if $rows != 3 then + return -1 +endi +sql select t1 from sta where t1 like '%ax%'; +if $rows != 0 then + return -1 +endi +sql select t1 from sta where t1 like '%cd%'; +if $rows != 0 then + return -1 +endi +sql select t1 from sta where t1 like '%ii'; +if $rows != 2 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT -- GitLab