diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index fe6c0ae463..8b50cd20ae 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -379,13 +379,13 @@ int32_t doOpenSortOperator(SOperatorInfo* pOperator) { code = tsortOpen(pInfo->pSortHandle); 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; } diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index fa1ccc3100..5a6428a30e 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -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, uint32_t pqSortBufSize, SSortHandle** pHandle) { int32_t code = 0; - *pHandle = NULL; + int32_t lino = 0; + QRY_OPTR_CHECK(pHandle); SSortHandle* pSortHandle = taosMemoryCalloc(1, sizeof(SSortHandle)); - if (pSortHandle == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } + QUERY_CHECK_NULL(pSortHandle, code, lino, _err, terrno); pSortHandle->type = type; pSortHandle->pageSize = pageSize; pSortHandle->numOfPages = numOfPages; pSortHandle->pSortInfo = taosArrayDup(pSortInfo, NULL); - if (pSortHandle->pSortInfo == NULL) { - return terrno; - } + QUERY_CHECK_NULL(pSortHandle->pSortInfo, code, lino, _err, terrno); pSortHandle->loops = 0; - pSortHandle->pqMaxTupleLength = pqMaxTupleLength; if (pqMaxRows != 0) { pSortHandle->pqSortBufSize = pqSortBufSize; @@ -312,18 +308,13 @@ int32_t tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t pageSize, pSortHandle->forceUsePQSort = false; if (pBlock != NULL) { code = createOneDataBlock(pBlock, false, &pSortHandle->pDataBlock); - if (code) { - goto _err; - } + QUERY_CHECK_CODE(code, lino, _err); } pSortHandle->mergeLimit = -1; pSortHandle->pOrderedSource = taosArrayInit(4, POINTER_BYTES); - if (pSortHandle->pOrderedSource == NULL) { - code = terrno; - goto _err; - } + QUERY_CHECK_NULL(pSortHandle->pOrderedSource, code, lino, _err, terrno); pSortHandle->cmpParam.orderInfo = pSortInfo; pSortHandle->cmpParam.cmpGroupId = false; @@ -346,17 +337,17 @@ int32_t tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t pageSize, if (idstr != NULL) { pSortHandle->idStr = taosStrdup(idstr); - if (pSortHandle->idStr == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; - } + QUERY_CHECK_NULL(pSortHandle->idStr, code, lino, _err, terrno); } *pHandle = pSortHandle; return code; _err: - tsortDestroySortHandle(pSortHandle); + qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + if (pSortHandle) { + tsortDestroySortHandle(pSortHandle); + } return code; }