diff --git a/src/query/src/qFilterfunc.c b/src/query/src/qFilterfunc.c index 758a445afe67a02df86b8689bc8efdb7137d9db2..3828365ec287ec9a18793453b4c7f324bfc3bfcd 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 d97a8b753ae21f6e5e35ab5a92673f425f5cfc1b..c960e95a06b7155f4d8b5874ce4447a0c346fca7 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 a41a2b685c96c78f7ef3f20011c49e6c6a285d6b..efddf285d9bc9ffeb03b3a5ea31a7f2d48433db7 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'%'; // "%"