diff --git a/src/query/tests/patternMatchTest.cpp b/src/query/tests/patternMatchTest.cpp index 41156ce8ffcce87af4c275bc293d5f0b279a0dd8..fa2b58a10bd044491a2fabbaee6180c37320ae35 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 43caca3a7c4b2554ea58c1d8339d69e3bb790fef..4bac669dc07689129a241b7ace45c56ad4485ca4 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 53b508ca6f99b2aaf9c26568ad0be3d583421dd9..0be907c16ae20690e32eb2364f9b169f9e77f302 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