From 76742eefed3ad60d0684dc4f2507d6012bc00677 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 10 Mar 2022 17:23:25 +0800 Subject: [PATCH] [TS-207](query): fixed child table or normal table order by --- src/util/src/tcompare.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index 24263f61b5..b9a7704c35 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -183,16 +183,16 @@ int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight) { int32_t len1 = varDataLen(pLeft); int32_t len2 = varDataLen(pRight); - if (len1 != len2) { - return len1 > len2? 1:-1; - } else { - int32_t ret = strncmp(varDataVal(pLeft), varDataVal(pRight), len1); - if (ret == 0) { + int32_t ret = strncmp(varDataVal(pLeft), varDataVal(pRight), len1>len2 ? len2:len1); + if (ret == 0) { + if (len1 > len2) + return 1; + else if(len1 < len2) + return -1; + else return 0; - } else { - return ret > 0 ? 1:-1; - } } + return (ret < 0) ? -1 : 1; } int32_t compareLenPrefixedStrDesc(const void* pLeft, const void* pRight) { @@ -203,16 +203,16 @@ int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) { int32_t len1 = varDataLen(pLeft); int32_t len2 = varDataLen(pRight); - if (len1 != len2) { - return len1 > len2? 1:-1; - } else { - int32_t ret = memcmp((wchar_t*) pLeft, (wchar_t*) pRight, len1); - if (ret == 0) { + int32_t ret = tasoUcs4Compare(varDataVal(pLeft), varDataVal(pRight), len1>len2 ? len2:len1); + if (ret == 0) { + if (len1 > len2) + return 1; + else if(len1 < len2) + return -1; + else return 0; - } else { - return ret > 0 ? 1 : -1; - } } + return (ret < 0) ? -1 : 1; } int32_t compareLenPrefixedWStrDesc(const void* pLeft, const void* pRight) { -- GitLab