[to #51805003] fix PlOpaque memory leak

This commit is contained in:
obdev
2023-08-28 04:14:11 +00:00
committed by ob-robot
parent 7d7e01ea10
commit 1a7878549a
2 changed files with 18 additions and 6 deletions

View File

@ -7520,14 +7520,14 @@ int ObSPIService::store_result(ObPLExecCtx *ctx,
for (int64_t i = 0; OB_SUCC(ret) && i < calc_array->count(); ++i) { for (int64_t i = 0; OB_SUCC(ret) && i < calc_array->count(); ++i) {
ObObj tmp; ObObj tmp;
if (calc_array->at(i).is_pl_extend()) { if (calc_array->at(i).is_pl_extend()) {
pl::ObUserDefinedType::deep_copy_obj(*alloc, calc_array->at(i), tmp); OZ (pl::ObUserDefinedType::deep_copy_obj(*alloc, calc_array->at(i), tmp));
} else { } else {
OZ (ob_write_obj(*alloc, calc_array->at(i), tmp)); OZ (ob_write_obj(*alloc, calc_array->at(i), tmp));
} }
OX (calc_array->at(i) = tmp); OX (calc_array->at(i) = tmp);
} }
} }
OZ (store_datums(result_address, *calc_array, alloc, is_schema_object)); OZ (store_datums(result_address, *calc_array, alloc, ctx->exec_ctx_->get_my_session(), is_schema_object));
} }
} else if (is_question_mark_expression(*result_expr)) { //通过question mark访问得到的基础变量 } else if (is_question_mark_expression(*result_expr)) { //通过question mark访问得到的基础变量
int64_t param_idx = get_const_value(*result_expr).get_unknown(); int64_t param_idx = get_const_value(*result_expr).get_unknown();
@ -7783,8 +7783,11 @@ int ObSPIService::store_result(ObPLExecCtx *ctx,
return ret; return ret;
} }
int ObSPIService::store_datums(ObObj &dest_addr, const ObIArray<ObObj> &obj_array, int ObSPIService::store_datums(ObObj &dest_addr,
ObIAllocator *alloc, bool is_schema_object) ObIArray<ObObj> &obj_array,
ObIAllocator *alloc,
ObSQLSessionInfo *session_info,
bool is_schema_object)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (obj_array.empty() || OB_ISNULL(alloc)) { if (obj_array.empty() || OB_ISNULL(alloc)) {
@ -7850,6 +7853,15 @@ int ObSPIService::store_datums(ObObj &dest_addr, const ObIArray<ObObj> &obj_arra
OX (current_datum = reinterpret_cast<int64_t>(dest_addr.get_ext())); OX (current_datum = reinterpret_cast<int64_t>(dest_addr.get_ext()));
} }
if (OB_FAIL(ret)) {
for (int64_t i = 0; i < obj_array.count(); ++i) {
int tmp_ret = OB_SUCCESS;
if ((tmp_ret = ObUserDefinedType::destruct_obj(obj_array.at(i), session_info)) != OB_SUCCESS) {
LOG_WARN("failed to destruct obj, memory may leak", K(ret), K(tmp_ret), K(i), K(obj_array));
}
}
}
for (int64_t i = 0; OB_SUCC(ret) && !is_opaque && i < obj_array.count(); ++i) { for (int64_t i = 0; OB_SUCC(ret) && !is_opaque && i < obj_array.count(); ++i) {
if (OB_FAIL(store_datum(current_datum, obj_array.at(i)))) { if (OB_FAIL(store_datum(current_datum, obj_array.at(i)))) {
LOG_WARN("failed to arrange store", K(dest_addr), K(i), K(obj_array.at(i)), K(obj_array), K(ret)); LOG_WARN("failed to arrange store", K(dest_addr), K(i), K(obj_array.at(i)), K(obj_array), K(ret));

View File

@ -973,8 +973,8 @@ private:
ObIArray<ObDataType> &row_desc, ObIArray<ObDataType> &row_desc,
bool is_type_record); bool is_type_record);
static int store_datums(ObObj &dest_addr, const ObIArray<ObObj> &result, static int store_datums(ObObj &dest_addr, ObIArray<ObObj> &result,
ObIAllocator *alloc, bool is_schema_object); ObIAllocator *alloc, ObSQLSessionInfo *session_info, bool is_schema_object);
static int store_datum(int64_t &current_addr, const ObObj &obj); static int store_datum(int64_t &current_addr, const ObObj &obj);