From 5ae8c2f43edf434786af6bf0bd6bbcc54d782e09 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 17 Mar 2022 11:26:27 +0800 Subject: [PATCH] fix compare is value is NULL in nchar and binary type --- src/util/src/tcompare.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index cd914c3851..2ab5ddbbe0 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -180,6 +180,12 @@ int32_t compareDoubleValDesc(const void* pLeft, const void* pRight) { } int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight) { + bool leftIsNull = isNull(pLeft, TSDB_DATA_TYPE_BINARY); + bool rightIsNull = isNull(pRight, TSDB_DATA_TYPE_BINARY); + if(leftIsNull && rightIsNull) return 0; + else if(leftIsNull) return -1; + else if(rightIsNull) return 1; + int32_t len1 = varDataLen(pLeft); int32_t len2 = varDataLen(pRight); @@ -200,6 +206,12 @@ int32_t compareLenPrefixedStrDesc(const void* pLeft, const void* pRight) { } int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) { + bool leftIsNull = isNull(pLeft, TSDB_DATA_TYPE_NCHAR); + bool rightIsNull = isNull(pRight, TSDB_DATA_TYPE_NCHAR); + if(leftIsNull && rightIsNull) return 0; + else if(leftIsNull) return -1; + else if(rightIsNull) return 1; + int32_t len1 = varDataLen(pLeft); int32_t len2 = varDataLen(pRight); -- GitLab