From 1d98fdbf12fc2e92bae58c794967c4e4aa452cb9 Mon Sep 17 00:00:00 2001 From: xywang Date: Mon, 20 Dec 2021 19:51:00 +0800 Subject: [PATCH] [TS-821]: reverted some changes --- src/query/src/qFilterfunc.c | 11 +---------- src/util/inc/tcompare.h | 2 +- src/util/src/tcompare.c | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/query/src/qFilterfunc.c b/src/query/src/qFilterfunc.c index 758a445afe..3828365ec2 100644 --- a/src/query/src/qFilterfunc.c +++ b/src/query/src/qFilterfunc.c @@ -184,16 +184,7 @@ bool likeOperator(SColumnFilterElem *pFilter, const char *minval, const char *ma } else if (type == TSDB_DATA_TYPE_NCHAR) { SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; size_t size = (size_t)(pFilter->filterInfo.len/TSDB_NCHAR_SIZE); - void *pz = calloc(size + 1, TSDB_NCHAR_SIZE); - if (pz == NULL) { - return false; - } - - memcpy(pz, (void *) pFilter->filterInfo.pz, size * TSDB_NCHAR_SIZE); - int32_t ret = WCSPatternMatch((uint32_t *) pz, size, (uint32_t *) varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE, &info); - free(pz); - - return ret == TSDB_PATTERN_MATCH; + return WCSPatternMatch((uint32_t *) pFilter->filterInfo.pz, size, (uint32_t *) varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE, &info) == TSDB_PATTERN_MATCH; } else { return false; } diff --git a/src/util/inc/tcompare.h b/src/util/inc/tcompare.h index d97a8b753a..c960e95a06 100644 --- a/src/util/inc/tcompare.h +++ b/src/util/inc/tcompare.h @@ -44,7 +44,7 @@ typedef struct SPatternCompareInfo { int patternMatch(const char *pattern, const char *str, size_t size, const SPatternCompareInfo *pInfo); -int WCSPatternMatch(uint32_t *pattern, size_t paSize, uint32_t *str, size_t size, const SPatternCompareInfo *pInfo); +int WCSPatternMatch(const uint32_t *pattern, size_t paSize, const uint32_t *str, size_t size, const SPatternCompareInfo *pInfo); int32_t doCompare(const char* a, const char* b, int32_t type, size_t size); diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index a41a2b685c..efddf285d9 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -386,7 +386,7 @@ taosWcscspn (const uint32_t *wcs, const uint32_t *reject) return count; } -int WCSPatternMatch(uint32_t *patterStr, size_t paSize, uint32_t *str, size_t size, const SPatternCompareInfo *pInfo) { +int WCSPatternMatch(const uint32_t *patterStr, size_t paSize, const uint32_t *str, size_t size, const SPatternCompareInfo *pInfo) { wchar_t c, c1; wchar_t matchOne = L'_'; // "_" wchar_t matchAll = L'%'; // "%" -- GitLab