From 268c520ef80bd7d0f85c505374f3df7331b6526a Mon Sep 17 00:00:00 2001 From: slzhou Date: Tue, 13 Sep 2022 16:58:48 +0800 Subject: [PATCH] fix: add group index for result row --- src/query/inc/qExecutor.h | 1 + src/query/src/qExecutor.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index bde9b11601..bccb52a592 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -92,6 +92,7 @@ typedef struct SResultRow { char *key; // start key of current result row SHashObj *uniqueHash; // for unique function SHashObj *modeHash; // for unique function + int32_t groupIndex; // index in group result } SResultRow; typedef struct SResultRowCell { diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index f13d8e2154..a7e9d4a014 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -289,8 +289,8 @@ static int compareRowData(const void* a, const void* b, const void* userData) { char* in2 = NULL; SRowCompSupporter* supporter = (SRowCompSupporter*)userData; if (supporter->colData != NULL) { - in1 = supporter->colData + supporter->colBytes * TARRAY_ELEM_IDX(supporter->resultRows, pRow1); - in2 = supporter->colData + supporter->colBytes * TARRAY_ELEM_IDX(supporter->resultRows, pRow2); + in1 = supporter->colData + supporter->colBytes * pRow1->groupIndex; + in2 = supporter->colData + supporter->colBytes * pRow2->groupIndex; } else { SQueryRuntimeEnv* pRuntimeEnv = supporter->pRuntimeEnv; @@ -318,6 +318,7 @@ static int32_t getColDataFromGroupRes(SGroupResInfo* pGroupResInfo, SQueryRuntim int32_t numOfResult = 0; for (int32_t i = 0; i < numRows; ++i) { SResultRow* row = taosArrayGetP(pGroupResInfo->pRows, i); + row->groupIndex = i; tFilePage* page = getResBufPage(pRuntimeEnv->pResultBuf, row->pageId); int32_t rowsToCopy = 1; char* out = colData + numOfResult * colBytes; -- GitLab