diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index cd914c3851fa84b5992e1994c0cd9bf46f048d76..2ab5ddbbe0ac1025be72e69fe88050d2aa3f73ad 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);