From c5ccdfd4e9e5e1560dbe9717f803aa68c899b543 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 9 Jul 2022 11:06:41 +0800 Subject: [PATCH] fix(query): set the correct resource free flag. --- include/libs/function/function.h | 8 ++++---- source/libs/scalar/src/scalar.c | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 7722ed7ba1..4d27325d75 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -173,12 +173,12 @@ typedef struct tExprNode { void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)); typedef enum { - CREATED_COLDATA = 0x1, // the newly created column data needs to be destroyed. - INPUT_COLDATA = 0x2, // input column data should not be released. -} SCOLDATA_TYPE_E; + SHOULD_FREE_COLDATA = 0x1, // the newly created column data needs to be destroyed. + DELEGATED_MGMT_COLDATA = 0x2, // input column data should not be released. +} ECOLDATA_MGMT_TYPE_E; struct SScalarParam { - SCOLDATA_TYPE_E type; + ECOLDATA_MGMT_TYPE_E type; SColumnInfoData *columnData; SHashObj *pHashFilter; int32_t hashValueType; diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 5c8e148e2d..2cbe1e5c96 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -55,7 +55,7 @@ int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarPara } pParam->columnData = pColumnData; - pParam->type = CREATED_COLDATA; + pParam->type = SHOULD_FREE_COLDATA; return TSDB_CODE_SUCCESS; } @@ -162,7 +162,7 @@ void sclFreeRes(SHashObj *res) { void sclFreeParam(SScalarParam *param) { if (param->columnData != NULL) { colDataDestroy(param->columnData); - taosMemoryFree(param->columnData); + taosMemoryFreeClear(param->columnData); } if (param->pHashFilter != NULL) { @@ -568,9 +568,9 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp _return: for (int32_t i = 0; i < paramNum; ++i) { - if (params[i].type == CREATED_COLDATA) { + if (params[i].type == SHOULD_FREE_COLDATA) { colDataDestroy(params[i].columnData); - taosMemoryFree(params[i].columnData); + taosMemoryFreeClear(params[i].columnData); } } @@ -842,6 +842,7 @@ EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) { return DEAL_RES_ERROR; } + output.type = DELEGATED_MGMT_COLDATA; if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; return DEAL_RES_ERROR; @@ -876,6 +877,7 @@ EDealRes sclWalkOperator(SNode* pNode, SScalarCtx *ctx) { return DEAL_RES_ERROR; } + output.type = DELEGATED_MGMT_COLDATA; if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; return DEAL_RES_ERROR; -- GitLab