to issue<51805002>:fix pltemp memory leak

This commit is contained in:
hanr881
2023-08-28 07:40:28 +00:00
committed by ob-robot
parent d7c4c679db
commit 53e98c7750
4 changed files with 42 additions and 10 deletions

View File

@ -2121,6 +2121,13 @@ public:
else_->~ObPLStmtBlock();
else_ = NULL;
}
int64_t when_count = when_.count();
for (int64_t i = 0; i < when_count; ++i) {
ObPLStmt *ret = when_[i].body_;
if (OB_NOT_NULL(ret)) {
ret->~ObPLStmt();
}
}
}
virtual int64_t get_child_size() const override { return when_.count() + 1; }

View File

@ -3666,6 +3666,15 @@ int ObPLCollection::trim_collection_elem(int64_t trim_number)
} else if (0 == trim_number) {
// do nothing
} else {
ObObj *obj = static_cast<ObObj *>(get_data());
for (int64_t index = count_ - trim_number; OB_SUCC(ret) && index < count_; ++index) {
if (OB_FAIL(ObUserDefinedType::destruct_obj(obj[index], NULL))) {
LOG_WARN("failed to destruct obj", K(ret), K(obj[index]), K(index));
} else {
obj[index].set_type(ObMaxType);
}
}
if (OB_SUCC(ret)) {
count_ -= trim_number;
last_ = OB_INVALID_INDEX;
update_last_impl();
@ -3676,6 +3685,7 @@ int ObPLCollection::trim_collection_elem(int64_t trim_number)
}
}
}
}
return ret;
}

View File

@ -205,7 +205,8 @@ int ObExprUDF::process_in_params(const ObObj *objs_stack,
const ObIArray<ObUDFParamDesc> &params_desc,
const ObIArray<ObExprResType> &params_type,
ParamStore& iparams,
ObIAllocator &allocator)
ObIAllocator &allocator,
ObIArray<ObObj> *deep_in_objs)
{
int ret = OB_SUCCESS;
CK (0 == param_num || OB_NOT_NULL(objs_stack));
@ -221,6 +222,9 @@ int ObExprUDF::process_in_params(const ObObj *objs_stack,
if (need_deep_copy_in_parameter(
objs_stack, param_num, params_desc, params_type, objs_stack[i])) {
OZ (pl::ObUserDefinedType::deep_copy_obj(allocator, objs_stack[i], param, true));
if (OB_NOT_NULL(deep_in_objs)) {
OZ (deep_in_objs->push_back(param));
}
} else {
param.set_extend(objs_stack[i].get_ext(),
objs_stack[i].get_meta().get_extend_type(), objs_stack[i].get_val_len());
@ -481,6 +485,7 @@ int ObExprUDF::eval_udf(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res)
}
ObObj *objs = nullptr;
ObSEArray<ObObj, 2> deep_in_objs;
if (expr.arg_cnt_ > 0) {
objs = static_cast<ObObj *> (allocator.alloc(expr.arg_cnt_ * sizeof(ObObj)));
if (OB_ISNULL(objs)) {
@ -489,7 +494,7 @@ int ObExprUDF::eval_udf(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res)
}
OZ (fill_obj_stack(expr, ctx, objs));
OZ (process_in_params(
objs, expr.arg_cnt_, info->params_desc_, info->params_type_, *udf_params, alloc));
objs, expr.arg_cnt_, info->params_desc_, info->params_type_, *udf_params, alloc, &deep_in_objs));
}
if (OB_SUCC(ret) && info->is_udt_cons_) {
@ -634,6 +639,15 @@ int ObExprUDF::eval_udf(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res)
OZ (pl::ObUserDefinedType::destruct_obj(udf_params->at(0), ctx.exec_ctx_.get_my_session()));
}
}
if (deep_in_objs.count() > 0) {
int tmp = OB_SUCCESS;
for (int64_t i = 0; i < deep_in_objs.count(); ++i) {
tmp = pl::ObUserDefinedType::destruct_obj(deep_in_objs.at(i), ctx.exec_ctx_.get_my_session());
if (OB_SUCCESS != tmp) {
LOG_WARN("fail to destruct obj of in param", K(tmp));
}
}
}
if (need_end_stmt) {
session->set_end_stmt();
}

View File

@ -148,7 +148,8 @@ public:
const common::ObIArray<ObUDFParamDesc> &params_desc,
const common::ObIArray<ObExprResType> &params_type,
common::ParamStore& iparams,
common::ObIAllocator &allocator);
common::ObIAllocator &allocator,
ObIArray<ObObj> *deep_in_objs = NULL);
static int process_out_params(const common::ObObj *objs_stack,
int64_t param_num,
common::ParamStore& iparams,