to issue<51805002>:fix pltemp memory leak
This commit is contained in:
@ -2121,6 +2121,13 @@ public:
|
|||||||
else_->~ObPLStmtBlock();
|
else_->~ObPLStmtBlock();
|
||||||
else_ = NULL;
|
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; }
|
virtual int64_t get_child_size() const override { return when_.count() + 1; }
|
||||||
|
|||||||
@ -3666,6 +3666,15 @@ int ObPLCollection::trim_collection_elem(int64_t trim_number)
|
|||||||
} else if (0 == trim_number) {
|
} else if (0 == trim_number) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} 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;
|
count_ -= trim_number;
|
||||||
last_ = OB_INVALID_INDEX;
|
last_ = OB_INVALID_INDEX;
|
||||||
update_last_impl();
|
update_last_impl();
|
||||||
@ -3676,6 +3685,7 @@ int ObPLCollection::trim_collection_elem(int64_t trim_number)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -205,7 +205,8 @@ int ObExprUDF::process_in_params(const ObObj *objs_stack,
|
|||||||
const ObIArray<ObUDFParamDesc> ¶ms_desc,
|
const ObIArray<ObUDFParamDesc> ¶ms_desc,
|
||||||
const ObIArray<ObExprResType> ¶ms_type,
|
const ObIArray<ObExprResType> ¶ms_type,
|
||||||
ParamStore& iparams,
|
ParamStore& iparams,
|
||||||
ObIAllocator &allocator)
|
ObIAllocator &allocator,
|
||||||
|
ObIArray<ObObj> *deep_in_objs)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
CK (0 == param_num || OB_NOT_NULL(objs_stack));
|
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(
|
if (need_deep_copy_in_parameter(
|
||||||
objs_stack, param_num, params_desc, params_type, objs_stack[i])) {
|
objs_stack, param_num, params_desc, params_type, objs_stack[i])) {
|
||||||
OZ (pl::ObUserDefinedType::deep_copy_obj(allocator, objs_stack[i], param, true));
|
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 {
|
} else {
|
||||||
param.set_extend(objs_stack[i].get_ext(),
|
param.set_extend(objs_stack[i].get_ext(),
|
||||||
objs_stack[i].get_meta().get_extend_type(), objs_stack[i].get_val_len());
|
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;
|
ObObj *objs = nullptr;
|
||||||
|
ObSEArray<ObObj, 2> deep_in_objs;
|
||||||
if (expr.arg_cnt_ > 0) {
|
if (expr.arg_cnt_ > 0) {
|
||||||
objs = static_cast<ObObj *> (allocator.alloc(expr.arg_cnt_ * sizeof(ObObj)));
|
objs = static_cast<ObObj *> (allocator.alloc(expr.arg_cnt_ * sizeof(ObObj)));
|
||||||
if (OB_ISNULL(objs)) {
|
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 (fill_obj_stack(expr, ctx, objs));
|
||||||
OZ (process_in_params(
|
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_) {
|
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()));
|
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) {
|
if (need_end_stmt) {
|
||||||
session->set_end_stmt();
|
session->set_end_stmt();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -148,7 +148,8 @@ public:
|
|||||||
const common::ObIArray<ObUDFParamDesc> ¶ms_desc,
|
const common::ObIArray<ObUDFParamDesc> ¶ms_desc,
|
||||||
const common::ObIArray<ObExprResType> ¶ms_type,
|
const common::ObIArray<ObExprResType> ¶ms_type,
|
||||||
common::ParamStore& iparams,
|
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,
|
static int process_out_params(const common::ObObj *objs_stack,
|
||||||
int64_t param_num,
|
int64_t param_num,
|
||||||
common::ParamStore& iparams,
|
common::ParamStore& iparams,
|
||||||
|
|||||||
Reference in New Issue
Block a user