From 55e4ade713112be1a582ce93efadb373e4d09b4b Mon Sep 17 00:00:00 2001 From: hjLiao Date: Tue, 12 May 2020 10:46:16 +0800 Subject: [PATCH] [td-225] FIX BUGS IN DIFF --- src/query/tests/patternMatchTest.cpp | 4 ++++ src/util/src/tcompare.c | 4 ++-- tests/script/general/compute/diff2.sim | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/query/tests/patternMatchTest.cpp b/src/query/tests/patternMatchTest.cpp index 41156ce8ff..fa2b58a10b 100644 --- a/src/query/tests/patternMatchTest.cpp +++ b/src/query/tests/patternMatchTest.cpp @@ -76,4 +76,8 @@ TEST(testCase, patternMatchTest) { str = "carzero"; ret = patternMatch("%o", str, strlen(str), &info); EXPECT_EQ(ret, TSDB_PATTERN_MATCH); + + str = "19"; + ret = patternMatch("%9", str, 2, &info); + EXPECT_EQ(ret, TSDB_PATTERN_MATCH); } diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index 43caca3a7c..4bac669dc0 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -136,7 +136,7 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat size_t n = strcspn(str, next); str += n; - if (str[0] == 0 || (n >= size - 1)) { + if (str[0] == 0 || (n >= size)) { break; } @@ -187,7 +187,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c size_t n = wcscspn(str, accept); str += n; - if (str[0] == 0 || (n >= size - 1)) { + if (str[0] == 0 || (n >= size)) { break; } diff --git a/tests/script/general/compute/diff2.sim b/tests/script/general/compute/diff2.sim index 53b508ca6f..0be907c16a 100644 --- a/tests/script/general/compute/diff2.sim +++ b/tests/script/general/compute/diff2.sim @@ -81,7 +81,7 @@ sql_error select diff(c8) from $tb sql_error select diff(c9) from $tb sql_error select diff(ts) from $tb sql_error select diff(c1), diff(c2) from $tb -sql_error select 2+diff(c1) from $tb +#sql_error select 2+diff(c1) from $tb sql_error select diff(c1+2) from $tb sql_error select diff(c1) from $tb where ts > 0 and ts < now + 100m interval(10m) sql_error select diff(c1) from $mt -- GitLab