diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 29ffd900f2..892f7948b4 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1970,6 +1970,8 @@ int32_t createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, SExprInfo** // set the output buffer for the selectivity + tag query static int32_t setSelectValueColumnInfo(SqlFunctionCtx* pCtx, int32_t numOfOutput) { int32_t num = 0; + int32_t code = TSDB_CODE_SUCCESS; + int32_t lino = 0; SqlFunctionCtx* p = NULL; SqlFunctionCtx** pValCtx = taosMemoryCalloc(numOfOutput, POINTER_BYTES); @@ -1978,6 +1980,8 @@ static int32_t setSelectValueColumnInfo(SqlFunctionCtx* pCtx, int32_t numOfOutpu } SHashObj* pSelectFuncs = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); + QUERY_CHECK_NULL(pSelectFuncs, code, lino, _end, terrno); + for (int32_t i = 0; i < numOfOutput; ++i) { const char* pName = pCtx[i].pExpr->pExpr->_function.functionName; if ((strcmp(pName, "_select_value") == 0) || (strcmp(pName, "_group_key") == 0) || @@ -1991,8 +1995,8 @@ static int32_t setSelectValueColumnInfo(SqlFunctionCtx* pCtx, int32_t numOfOutpu } else { int32_t tempRes = taosHashPut(pSelectFuncs, pName, strlen(pName), &num, sizeof(num)); if (tempRes != TSDB_CODE_SUCCESS && tempRes != TSDB_CODE_DUP_KEY) { - qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(tempRes)); - return tempRes; + code = tempRes; + QUERY_CHECK_CODE(code, lino, _end); } p = &pCtx[i]; } @@ -2007,7 +2011,13 @@ static int32_t setSelectValueColumnInfo(SqlFunctionCtx* pCtx, int32_t numOfOutpu taosMemoryFreeClear(pValCtx); } - return TSDB_CODE_SUCCESS; +_end: + if (code != TSDB_CODE_SUCCESS) { + taosMemoryFreeClear(pValCtx); + taosHashCleanup(pSelectFuncs); + qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + } + return code; } SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowEntryInfoOffset, diff --git a/source/libs/executor/src/streamfilloperator.c b/source/libs/executor/src/streamfilloperator.c index fac1cf48c7..453e64a151 100644 --- a/source/libs/executor/src/streamfilloperator.c +++ b/source/libs/executor/src/streamfilloperator.c @@ -1207,7 +1207,12 @@ static SStreamFillSupporter* initStreamFillSup(SStreamFillPhysiNode* pPhyFillNod pFillSup->pAllColInfo = createFillColInfo(pFillExprInfo, pFillSup->numOfFillCols, noFillExprInfo, numOfNotFillCols, (const SNodeListNode*)(pPhyFillNode->pValues)); - QUERY_CHECK_NULL(pFillSup->pAllColInfo, code, lino, _end, terrno); + if (pFillSup->pAllColInfo == NULL) { + code = terrno; + lino = __LINE__; + destroyExprInfo(noFillExprInfo, numOfNotFillCols); + goto _end; + } pFillSup->type = convertFillType(pPhyFillNode->mode); pFillSup->numOfAllCols = pFillSup->numOfFillCols + numOfNotFillCols;