to issue<47065195>:fix memory leak of pl temp when using udf in sql stmt

This commit is contained in:
obdev
2023-01-04 14:08:13 +00:00
committed by ob-robot
parent 30b78e5855
commit a09a9911fe
2 changed files with 5 additions and 2 deletions

View File

@ -631,7 +631,7 @@ class ObPLCtxGuard
{
public:
ObPLCtxGuard(ObPLCtx *ctx, int& ret) : ctx_(ctx), ret_(ret) {
if (OB_NOT_NULL(ctx)) {
if (OB_SUCCESS == ret_ && OB_NOT_NULL(ctx)) {
ret_ = objects_.assign(ctx->get_objects());
ctx_->clear();
}
@ -639,7 +639,9 @@ public:
~ObPLCtxGuard() {
if (OB_SUCCESS == ret_ && OB_NOT_NULL(ctx_)) {
ret_ = ctx_->get_objects().assign(objects_);
for (int64_t i = 0; OB_SUCCESS == ret_ && i < objects_.count(); ++i) {
ret_ = ctx_->add(objects_.at(i));
}
}
}

View File

@ -522,6 +522,7 @@ int ObExprUDF::eval_udf(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res)
OZ (ctx.exec_ctx_.get_pl_ctx()->add(result));
} else {
OZ (deep_copy_obj(alloc, tmp_result, result));
OX (ctx.exec_ctx_.get_pl_ctx()->reset_obj());
}
} else {
result = tmp_result;