fix(query): fix memory leak.
This commit is contained in:
parent
9aac625068
commit
82ad1958f4
|
@ -379,13 +379,13 @@ int32_t doOpenSortOperator(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
code = tsortOpen(pInfo->pSortHandle);
|
code = tsortOpen(pInfo->pSortHandle);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
pTaskInfo->code = code;
|
||||||
|
} else {
|
||||||
|
pOperator->cost.openCost = (taosGetTimestampUs() - pInfo->startTs) / 1000.0;
|
||||||
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
|
OPTR_SET_OPENED(pOperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
pOperator->cost.openCost = (taosGetTimestampUs() - pInfo->startTs) / 1000.0;
|
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
|
||||||
|
|
||||||
OPTR_SET_OPENED(pOperator);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -286,23 +286,19 @@ int32_t tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t pageSize,
|
||||||
SSDataBlock* pBlock, const char* idstr, uint64_t pqMaxRows, uint32_t pqMaxTupleLength,
|
SSDataBlock* pBlock, const char* idstr, uint64_t pqMaxRows, uint32_t pqMaxTupleLength,
|
||||||
uint32_t pqSortBufSize, SSortHandle** pHandle) {
|
uint32_t pqSortBufSize, SSortHandle** pHandle) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
*pHandle = NULL;
|
int32_t lino = 0;
|
||||||
|
|
||||||
|
QRY_OPTR_CHECK(pHandle);
|
||||||
SSortHandle* pSortHandle = taosMemoryCalloc(1, sizeof(SSortHandle));
|
SSortHandle* pSortHandle = taosMemoryCalloc(1, sizeof(SSortHandle));
|
||||||
if (pSortHandle == NULL) {
|
QUERY_CHECK_NULL(pSortHandle, code, lino, _err, terrno);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
pSortHandle->type = type;
|
pSortHandle->type = type;
|
||||||
pSortHandle->pageSize = pageSize;
|
pSortHandle->pageSize = pageSize;
|
||||||
pSortHandle->numOfPages = numOfPages;
|
pSortHandle->numOfPages = numOfPages;
|
||||||
pSortHandle->pSortInfo = taosArrayDup(pSortInfo, NULL);
|
pSortHandle->pSortInfo = taosArrayDup(pSortInfo, NULL);
|
||||||
if (pSortHandle->pSortInfo == NULL) {
|
QUERY_CHECK_NULL(pSortHandle->pSortInfo, code, lino, _err, terrno);
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
pSortHandle->loops = 0;
|
pSortHandle->loops = 0;
|
||||||
|
|
||||||
pSortHandle->pqMaxTupleLength = pqMaxTupleLength;
|
pSortHandle->pqMaxTupleLength = pqMaxTupleLength;
|
||||||
if (pqMaxRows != 0) {
|
if (pqMaxRows != 0) {
|
||||||
pSortHandle->pqSortBufSize = pqSortBufSize;
|
pSortHandle->pqSortBufSize = pqSortBufSize;
|
||||||
|
@ -312,18 +308,13 @@ int32_t tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t pageSize,
|
||||||
pSortHandle->forceUsePQSort = false;
|
pSortHandle->forceUsePQSort = false;
|
||||||
if (pBlock != NULL) {
|
if (pBlock != NULL) {
|
||||||
code = createOneDataBlock(pBlock, false, &pSortHandle->pDataBlock);
|
code = createOneDataBlock(pBlock, false, &pSortHandle->pDataBlock);
|
||||||
if (code) {
|
QUERY_CHECK_CODE(code, lino, _err);
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pSortHandle->mergeLimit = -1;
|
pSortHandle->mergeLimit = -1;
|
||||||
|
|
||||||
pSortHandle->pOrderedSource = taosArrayInit(4, POINTER_BYTES);
|
pSortHandle->pOrderedSource = taosArrayInit(4, POINTER_BYTES);
|
||||||
if (pSortHandle->pOrderedSource == NULL) {
|
QUERY_CHECK_NULL(pSortHandle->pOrderedSource, code, lino, _err, terrno);
|
||||||
code = terrno;
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
pSortHandle->cmpParam.orderInfo = pSortInfo;
|
pSortHandle->cmpParam.orderInfo = pSortInfo;
|
||||||
pSortHandle->cmpParam.cmpGroupId = false;
|
pSortHandle->cmpParam.cmpGroupId = false;
|
||||||
|
@ -346,17 +337,17 @@ int32_t tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t pageSize,
|
||||||
|
|
||||||
if (idstr != NULL) {
|
if (idstr != NULL) {
|
||||||
pSortHandle->idStr = taosStrdup(idstr);
|
pSortHandle->idStr = taosStrdup(idstr);
|
||||||
if (pSortHandle->idStr == NULL) {
|
QUERY_CHECK_NULL(pSortHandle->idStr, code, lino, _err, terrno);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*pHandle = pSortHandle;
|
*pHandle = pSortHandle;
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsortDestroySortHandle(pSortHandle);
|
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
if (pSortHandle) {
|
||||||
|
tsortDestroySortHandle(pSortHandle);
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue