diff --git a/include/util/types.h b/include/util/types.h index ded9dc37d7163f833b5f6959656617c7533b195c..1360307156ab726b274f45e18dc607798941804f 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 cf4701ced805ae666a4865538966f31ae4616478..e828daf00215fbedc450bcaca4f93260c61de3f4 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 11a1cc1c7174ebf803274a36e42f347eef091b16..fe3065b2b78a46a85d6dc04b90fcff4e0fe80f03 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) {