enh:[TD-30998] Handling memory release when error occurred.
This commit is contained in:
parent
e7c58ff8c8
commit
e1bcd84426
|
@ -957,6 +957,7 @@ int32_t filterDetachCnfGroup(SFilterGroup *gp1, SFilterGroup *gp2, SArray *group
|
||||||
gp.unitFlags = NULL;
|
gp.unitFlags = NULL;
|
||||||
|
|
||||||
if (NULL == taosArrayPush(group, &gp)) {
|
if (NULL == taosArrayPush(group, &gp)) {
|
||||||
|
taosMemoryFreeClear(gp.unitIdxs);
|
||||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1267,9 +1268,9 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) {
|
||||||
if (valueNode->node.resType.type != type) {
|
if (valueNode->node.resType.type != type) {
|
||||||
int32_t overflow = 0;
|
int32_t overflow = 0;
|
||||||
code = sclConvertValueToSclParam(valueNode, &out, &overflow);
|
code = sclConvertValueToSclParam(valueNode, &out, &overflow);
|
||||||
if (code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
// fltError("convert from %d to %d failed", in.type, out.type);
|
// fltError("convert from %d to %d failed", in.type, out.type);
|
||||||
FLT_ERR_RET(code);
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overflow) {
|
if (overflow) {
|
||||||
|
@ -1306,7 +1307,8 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (NULL == taosArrayPush(group, &fgroup)) {
|
if (NULL == taosArrayPush(group, &fgroup)) {
|
||||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cell = cell->pNext;
|
cell = cell->pNext;
|
||||||
|
@ -2337,6 +2339,7 @@ _return:
|
||||||
|
|
||||||
int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t *gResNum) {
|
int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t *gResNum) {
|
||||||
bool empty = false;
|
bool empty = false;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
uint32_t colIdxi = 0;
|
uint32_t colIdxi = 0;
|
||||||
uint32_t gResIdx = 0;
|
uint32_t gResIdx = 0;
|
||||||
uint32_t *colIdx = taosMemoryMalloc(info->fields[FLD_TYPE_COLUMN].num * sizeof(uint32_t));
|
uint32_t *colIdx = taosMemoryMalloc(info->fields[FLD_TYPE_COLUMN].num * sizeof(uint32_t));
|
||||||
|
@ -2348,11 +2351,11 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
|
||||||
|
|
||||||
gRes[gResIdx] = taosMemoryCalloc(1, sizeof(SFilterGroupCtx));
|
gRes[gResIdx] = taosMemoryCalloc(1, sizeof(SFilterGroupCtx));
|
||||||
if (gRes[gResIdx] == NULL) {
|
if (gRes[gResIdx] == NULL) {
|
||||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
gRes[gResIdx]->colInfo = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(SFilterColInfo));
|
gRes[gResIdx]->colInfo = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(SFilterColInfo));
|
||||||
if (gRes[gResIdx]->colInfo == NULL) {
|
if (gRes[gResIdx]->colInfo == NULL) {
|
||||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
colIdxi = 0;
|
colIdxi = 0;
|
||||||
empty = false;
|
empty = false;
|
||||||
|
@ -2364,7 +2367,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
|
||||||
if (gRes[gResIdx]->colInfo[cidx].info == NULL) {
|
if (gRes[gResIdx]->colInfo[cidx].info == NULL) {
|
||||||
gRes[gResIdx]->colInfo[cidx].info = (SArray *)taosArrayInit(4, POINTER_BYTES);
|
gRes[gResIdx]->colInfo[cidx].info = (SArray *)taosArrayInit(4, POINTER_BYTES);
|
||||||
if (gRes[gResIdx]->colInfo[cidx].info == NULL) {
|
if (gRes[gResIdx]->colInfo[cidx].info == NULL) {
|
||||||
FLT_ERR_RET(terrno);
|
FLT_ERR_JRET(terrno);
|
||||||
}
|
}
|
||||||
colIdx[colIdxi++] = cidx;
|
colIdx[colIdxi++] = cidx;
|
||||||
++gRes[gResIdx]->colNum;
|
++gRes[gResIdx]->colNum;
|
||||||
|
@ -2388,7 +2391,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLT_ERR_RET(filterMergeUnits(info, gRes[gResIdx], colIdx[l], &empty));
|
FLT_ERR_JRET(filterMergeUnits(info, gRes[gResIdx], colIdx[l], &empty));
|
||||||
|
|
||||||
if (empty) {
|
if (empty) {
|
||||||
break;
|
break;
|
||||||
|
@ -2408,15 +2411,15 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t
|
||||||
++gResIdx;
|
++gResIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(colIdx);
|
|
||||||
|
|
||||||
*gResNum = gResIdx;
|
*gResNum = gResIdx;
|
||||||
|
|
||||||
if (gResIdx == 0) {
|
if (gResIdx == 0) {
|
||||||
FILTER_SET_FLAG(info->status, FI_STATUS_EMPTY);
|
FILTER_SET_FLAG(info->status, FI_STATUS_EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
_return:
|
||||||
|
taosMemoryFreeClear(colIdx);
|
||||||
|
FLT_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool filterIsSameUnits(SFilterColInfo *pCol1, SFilterColInfo *pCol2) {
|
bool filterIsSameUnits(SFilterColInfo *pCol1, SFilterColInfo *pCol2) {
|
||||||
|
@ -2956,15 +2959,9 @@ int32_t filterPostProcessRange(SFilterInfo *info) {
|
||||||
|
|
||||||
int32_t filterGenerateComInfo(SFilterInfo *info) {
|
int32_t filterGenerateComInfo(SFilterInfo *info) {
|
||||||
info->cunits = taosMemoryMalloc(info->unitNum * sizeof(*info->cunits));
|
info->cunits = taosMemoryMalloc(info->unitNum * sizeof(*info->cunits));
|
||||||
if (NULL == info->cunits) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
info->blkUnitRes = taosMemoryMalloc(sizeof(*info->blkUnitRes) * info->unitNum);
|
info->blkUnitRes = taosMemoryMalloc(sizeof(*info->blkUnitRes) * info->unitNum);
|
||||||
if (NULL == info->blkUnitRes) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
info->blkUnits = taosMemoryMalloc(sizeof(*info->blkUnits) * (info->unitNum + 1) * info->groupNum);
|
info->blkUnits = taosMemoryMalloc(sizeof(*info->blkUnits) * (info->unitNum + 1) * info->groupNum);
|
||||||
if (NULL == info->blkUnits) {
|
if (NULL == info->cunits || NULL == info->blkUnitRes || NULL == info->blkUnits) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3427,6 +3424,7 @@ int32_t filterExecuteImplMisc(void *pinfo, int32_t numOfRows, SColumnInfoData *p
|
||||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(colData), varDataLen(colData), varDataVal(newColData));
|
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(colData), varDataLen(colData), varDataVal(newColData));
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
qError("castConvert1 taosUcs4ToMbs error");
|
qError("castConvert1 taosUcs4ToMbs error");
|
||||||
|
taosMemoryFreeClear(newColData);
|
||||||
FLT_ERR_RET(TSDB_CODE_APP_ERROR);
|
FLT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||||
} else {
|
} else {
|
||||||
varDataSetLen(newColData, len);
|
varDataSetLen(newColData, len);
|
||||||
|
@ -3501,6 +3499,7 @@ int32_t filterExecuteImpl(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes,
|
||||||
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(colData), varDataLen(colData), varDataVal(newColData));
|
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(colData), varDataLen(colData), varDataVal(newColData));
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
qError("castConvert1 taosUcs4ToMbs error");
|
qError("castConvert1 taosUcs4ToMbs error");
|
||||||
|
taosMemoryFreeClear(newColData);
|
||||||
FLT_ERR_RET(TSDB_CODE_APP_ERROR);
|
FLT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||||
} else {
|
} else {
|
||||||
varDataSetLen(newColData, len);
|
varDataSetLen(newColData, len);
|
||||||
|
|
|
@ -1234,6 +1234,7 @@ EDealRes sclRewriteFunction(SNode **pNode, SScalarCtx *ctx) {
|
||||||
if (NULL == res->datum.p) {
|
if (NULL == res->datum.p) {
|
||||||
sclError("calloc %d failed", len);
|
sclError("calloc %d failed", len);
|
||||||
sclFreeParam(&output);
|
sclFreeParam(&output);
|
||||||
|
nodesDestroyNode((SNode *)res);
|
||||||
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1244,6 +1245,7 @@ EDealRes sclRewriteFunction(SNode **pNode, SScalarCtx *ctx) {
|
||||||
if (NULL == res->datum.p) {
|
if (NULL == res->datum.p) {
|
||||||
sclError("calloc %d failed", (int)(varDataTLen(output.columnData->pData) + 1));
|
sclError("calloc %d failed", (int)(varDataTLen(output.columnData->pData) + 1));
|
||||||
sclFreeParam(&output);
|
sclFreeParam(&output);
|
||||||
|
nodesDestroyNode((SNode *)res);
|
||||||
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1253,6 +1255,7 @@ EDealRes sclRewriteFunction(SNode **pNode, SScalarCtx *ctx) {
|
||||||
ctx->code = nodesSetValueNodeValue(res, output.columnData->pData);
|
ctx->code = nodesSetValueNodeValue(res, output.columnData->pData);
|
||||||
if (ctx->code) {
|
if (ctx->code) {
|
||||||
sclFreeParam(&output);
|
sclFreeParam(&output);
|
||||||
|
nodesDestroyNode((SNode *)res);
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1415,6 +1418,7 @@ EDealRes sclRewriteCaseWhen(SNode **pNode, SScalarCtx *ctx) {
|
||||||
if (NULL == res->datum.p) {
|
if (NULL == res->datum.p) {
|
||||||
sclError("calloc %d failed", (int)(varDataTLen(output.columnData->pData) + 1));
|
sclError("calloc %d failed", (int)(varDataTLen(output.columnData->pData) + 1));
|
||||||
sclFreeParam(&output);
|
sclFreeParam(&output);
|
||||||
|
nodesDestroyNode((SNode *)res);
|
||||||
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1423,6 +1427,7 @@ EDealRes sclRewriteCaseWhen(SNode **pNode, SScalarCtx *ctx) {
|
||||||
ctx->code = nodesSetValueNodeValue(res, output.columnData->pData);
|
ctx->code = nodesSetValueNodeValue(res, output.columnData->pData);
|
||||||
if (ctx->code) {
|
if (ctx->code) {
|
||||||
sclFreeParam(&output);
|
sclFreeParam(&output);
|
||||||
|
nodesDestroyNode((SNode *)res);
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2731,6 +2731,7 @@ static int32_t getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *
|
||||||
|
|
||||||
intervals = taosMemoryCalloc(numOfBins, sizeof(double));
|
intervals = taosMemoryCalloc(numOfBins, sizeof(double));
|
||||||
if (NULL == intervals) {
|
if (NULL == intervals) {
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
if (cJSON_IsNumber(width) && factor == NULL && binType == LINEAR_BIN) {
|
if (cJSON_IsNumber(width) && factor == NULL && binType == LINEAR_BIN) {
|
||||||
|
@ -2795,6 +2796,7 @@ static int32_t getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *
|
||||||
numOfBins = cJSON_GetArraySize(binDesc);
|
numOfBins = cJSON_GetArraySize(binDesc);
|
||||||
intervals = taosMemoryCalloc(numOfBins, sizeof(double));
|
intervals = taosMemoryCalloc(numOfBins, sizeof(double));
|
||||||
if (NULL == intervals) {
|
if (NULL == intervals) {
|
||||||
|
cJSON_Delete(binDesc);
|
||||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
cJSON *bin = binDesc->child;
|
cJSON *bin = binDesc->child;
|
||||||
|
|
Loading…
Reference in New Issue