From 8390080074fcf50c00f7537b2680b20c89c7d0e4 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Sat, 2 Jul 2022 16:16:18 +0800 Subject: [PATCH] fix: error in empty string in operator --- include/util/types.h | 1 + source/libs/scalar/src/scalar.c | 8 +++----- source/util/src/tcompare.c | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/util/types.h b/include/util/types.h index ded9dc37d7..1360307156 100644 --- a/include/util/types.h +++ b/include/util/types.h @@ -83,6 +83,7 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 32767 #define varDataLen(v) ((VarDataLenT *)(v))[0] #define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE) +#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v)) #define NCHAR_WIDTH_TO_BYTES(n) ((n) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE) diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index cf4701ced8..e828daf002 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -109,9 +109,8 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { } if (IS_VAR_DATA_TYPE(type)) { - char* data = colDataGetVarData(out.columnData, 0); - len = varDataLen(data); - buf = varDataVal(data); + buf = colDataGetVarData(out.columnData, 0); + len = varDataTLen(data); } else { len = tDataTypes[type].bytes; buf = out.columnData->pData; @@ -119,8 +118,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { } else { buf = nodesGetValueFromNode(valueNode); if (IS_VAR_DATA_TYPE(type)) { - len = varDataLen(buf); - buf = varDataVal(buf); + len = varDataTLen(buf); } else { len = valueNode->node.resType.bytes; } diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index 11a1cc1c71..fe3065b2b7 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -56,11 +56,11 @@ int32_t setChkNotInBytes8(const void *pLeft, const void *pRight) { } int32_t compareChkInString(const void *pLeft, const void *pRight) { - return NULL != taosHashGet((SHashObj *)pRight, varDataVal(pLeft), varDataLen(pLeft)) ? 1 : 0; + return NULL != taosHashGet((SHashObj *)pRight, pLeft, varDataTLen(pLeft)) ? 1 : 0; } int32_t compareChkNotInString(const void *pLeft, const void *pRight) { - return NULL == taosHashGet((SHashObj *)pRight, varDataVal(pLeft), varDataLen(pLeft)) ? 1 : 0; + return NULL == taosHashGet((SHashObj *)pRight, pLeft, varDataTLen(pLeft)) ? 1 : 0; } int32_t compareInt8Val(const void *pLeft, const void *pRight) {