diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 19149028eaa2ae0be7a7350b10592f3cda191d09..658302e16929abe05e5bbb6847bc3eda6231ced4 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -217,6 +217,17 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) { nodesDestroyNode(pStmt->pSlimit); break; } + case QUERY_NODE_VNODE_MODIF_STMT: { + SVnodeModifOpStmt* pStmt = (SVnodeModifOpStmt*)*pNode; + size_t size = taosArrayGetSize(pStmt->pDataBlocks); + for (size_t i = 0; i < size; ++i) { + SVgDataBlocks* pVg = taosArrayGetP(pStmt->pDataBlocks, i); + tfree(pVg->pData); + tfree(pVg); + } + taosArrayDestroy(pStmt->pDataBlocks); + break; + } case QUERY_NODE_CREATE_TABLE_STMT: { SCreateTableStmt* pStmt = (SCreateTableStmt*)*pNode; nodesDestroyList(pStmt->pCols); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 78212e7c1ac45a971d9e6307c59fb248d45a4fb0..9e563235dc5387630c148defa24403224a15e0ff 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -847,6 +847,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); if (NULL== pCxt->pCmdMsg) { + tFreeSMCreateStbReq(&createReq); return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; @@ -854,10 +855,12 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt pCxt->pCmdMsg->msgLen = tSerializeSMCreateStbReq(NULL, 0, &createReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); if (NULL== pCxt->pCmdMsg->pMsg) { + tFreeSMCreateStbReq(&createReq); return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSMCreateStbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); + tFreeSMCreateStbReq(&createReq); return TSDB_CODE_SUCCESS; } @@ -1211,14 +1214,12 @@ static int32_t setReslutSchema(STranslateContext* pCxt, SQuery* pQuery) { static void destroyTranslateContext(STranslateContext* pCxt) { if (NULL != pCxt->pNsLevel) { - - } - - size_t size = taosArrayGetSize(pCxt->pNsLevel); - for (size_t i = 0; i < size; ++i) { - taosArrayDestroy(taosArrayGetP(pCxt->pNsLevel, i)); + size_t size = taosArrayGetSize(pCxt->pNsLevel); + for (size_t i = 0; i < size; ++i) { + taosArrayDestroy(taosArrayGetP(pCxt->pNsLevel, i)); + } + taosArrayDestroy(pCxt->pNsLevel); } - taosArrayDestroy(pCxt->pNsLevel); if (NULL != pCxt->pCmdMsg) { tfree(pCxt->pCmdMsg->pMsg); @@ -1306,8 +1307,6 @@ static void destroyCreateTbReqBatch(SVgroupTablesBatch* pTbBatch) { tfree(pTableReq->ntbCfg.pSchema); } else if (pTableReq->type == TSDB_CHILD_TABLE) { tfree(pTableReq->ctbCfg.pTag); - } else { - assert(0); } } @@ -1333,6 +1332,16 @@ static int32_t rewriteToVnodeModifOpStmt(SQuery* pQuery, SArray* pBufArray) { return TSDB_CODE_SUCCESS; } +static void destroyCreateTbReqArray(SArray* pArray) { + size_t size = taosArrayGetSize(pArray); + for (size_t i = 0; i < size; ++i) { + SVgDataBlocks* pVg = taosArrayGetP(pArray, i); + tfree(pVg->pData); + tfree(pVg); + } + taosArrayDestroy(pArray); +} + static int32_t buildCreateTableDataBlock(const SCreateTableStmt* pStmt, const SVgroupInfo* pInfo, SArray** pBufArray) { *pBufArray = taosArrayInit(1, POINTER_BYTES); if (NULL == *pBufArray) { @@ -1344,9 +1353,10 @@ static int32_t buildCreateTableDataBlock(const SCreateTableStmt* pStmt, const SV if (TSDB_CODE_SUCCESS == code) { code = serializeVgroupTablesBatch(&tbatch, *pBufArray); } + destroyCreateTbReqBatch(&tbatch); if (TSDB_CODE_SUCCESS != code) { - // todo : destroyCreateTbReqArray(*pBufArray); + destroyCreateTbReqArray(*pBufArray); } return code; } @@ -1362,6 +1372,9 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) { } if (TSDB_CODE_SUCCESS == code) { code = rewriteToVnodeModifOpStmt(pQuery, pBufArray); + if (TSDB_CODE_SUCCESS != code) { + destroyCreateTbReqArray(pBufArray); + } } return code; @@ -1573,10 +1586,10 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery) } SArray* pBufArray = serializeVgroupsTablesBatch(pVgroupHashmap); + taosHashCleanup(pVgroupHashmap); if (NULL == pBufArray) { return TSDB_CODE_OUT_OF_MEMORY; } - taosHashCleanup(pVgroupHashmap); return rewriteToVnodeModifOpStmt(pQuery, pBufArray); }