From 3711d425ae512545c2c15d9c054bc2cecfeb25fd Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Fri, 18 Feb 2022 18:42:13 +0800 Subject: [PATCH] fix unique hashobj in unique --- src/query/src/qAggMain.c | 6 +++++- src/query/src/qExecutor.c | 12 +++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index b7862a96fc..b02b8e8484 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -5190,7 +5190,11 @@ static bool unique_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pRes if (!function_setup(pCtx, pResInfo)) { return false; } - *pCtx->pUniqueSet = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if(*pCtx->pUniqueSet != NULL){ + taosHashClear(*pCtx->pUniqueSet); + }else{ + *pCtx->pUniqueSet = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + } return true; } diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 2920158b6d..9a4fc2b810 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -3688,7 +3688,9 @@ void setDefaultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, i RESET_RESULT_INFO(pCellInfo); pCtx[i].resultInfo = pCellInfo; - pCtx[i].pUniqueSet = &pRow->uniqueHash; + if (pCtx[i].functionId == TSDB_FUNC_UNIQUE) { + pCtx[i].pUniqueSet = &pRow->uniqueHash; + } pCtx[i].pOutput = pData->pData; pCtx[i].currentStage = stage; assert(pCtx[i].pOutput != NULL); @@ -4023,7 +4025,9 @@ void setResultRowOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pRe int32_t offset = 0; for (int32_t i = 0; i < numOfOutput; ++i) { pCtx[i].resultInfo = getResultCell(pResult, i, rowCellInfoOffset); - pCtx[i].pUniqueSet = &pResult->uniqueHash; + if (pCtx[i].functionId == TSDB_FUNC_UNIQUE){ + pCtx[i].pUniqueSet = &pResult->uniqueHash; + } SResultRowCellInfo* pResInfo = pCtx[i].resultInfo; if (pResInfo->initialized && pResInfo->complete) { @@ -4117,7 +4121,9 @@ void setResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResult, SQLF * not all queries require the interResultBuf, such as COUNT */ pCtx[i].resultInfo = getResultCell(pResult, i, rowCellInfoOffset); - pCtx[i].pUniqueSet = &pResult->uniqueHash; + if (pCtx[i].functionId == TSDB_FUNC_UNIQUE) { + pCtx[i].pUniqueSet = &pResult->uniqueHash; + } } } -- GitLab