From 0bb872c1d9eac81532e97044ee0ee5b74372b627 Mon Sep 17 00:00:00 2001 From: factosea <285808407@qq.com> Date: Tue, 12 Nov 2024 15:03:48 +0800 Subject: [PATCH] enh: command/explain --- source/libs/command/src/command.c | 3 ++- source/libs/command/src/explain.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 5afdf87afb..3c332a6b06 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -56,6 +56,7 @@ static int32_t buildRetrieveTableRsp(SSDataBlock* pBlock, int32_t numOfCols, SRe int32_t len = blockEncode(pBlock, (*pRsp)->data + PAYLOAD_PREFIX_LEN, dataEncodeBufSize, numOfCols); if(len < 0) { taosMemoryFree(*pRsp); + *pRsp = NULL; return terrno; } SET_PAYLOAD_LEN((*pRsp)->data, len, len); @@ -957,8 +958,8 @@ static int32_t buildLocalVariablesResultDataBlock(SSDataBlock** pOutput) { _exit: if (terrno != TSDB_CODE_SUCCESS) { - taosMemoryFree(pBlock); taosArrayDestroy(pBlock->pDataBlock); + taosMemoryFree(pBlock); } return terrno; } diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index 3ab739334d..24b43ac95b 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -2112,6 +2112,7 @@ static int32_t qExplainGenerateRsp(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp) } int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t groupId, SRetrieveTableRsp **pRsp) { + if(!pCtx || !pRspMsg || !pRsp) return TSDB_CODE_INVALID_PARA; SExplainResNode *node = NULL; int32_t code = 0; bool groupDone = false; @@ -2176,6 +2177,7 @@ _exit: } int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp) { + if (!pDag || !pRsp) return TSDB_CODE_INVALID_PARA; int32_t code = 0; SExplainCtx *pCtx = NULL; @@ -2188,6 +2190,7 @@ _return: } int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs) { + if(!pDag || !pCtx) return TSDB_CODE_INVALID_PARA; QRY_ERR_RET(qExplainPrepareCtx(pDag, pCtx)); (*pCtx)->reqStartTs = startTs; @@ -2197,6 +2200,7 @@ int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs) } int32_t qExecExplainEnd(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp) { + if(!pCtx || !pRsp) return TSDB_CODE_INVALID_PARA; int32_t code = 0; pCtx->jobDoneTs = taosGetTimestampUs();