[to #47336750] fix memory leak of package variable serialize

This commit is contained in:
obdev
2023-02-15 04:11:44 +00:00
committed by ob-robot
parent adce321d1b
commit 2b5d89226f
3 changed files with 7 additions and 4 deletions

View File

@ -758,7 +758,7 @@ int ObPLPackageManager::set_package_var_val(const ObPLResolveCtx &resolve_ctx,
ret = OB_ERR_NUMERIC_OR_VALUE_ERROR;
LOG_WARN("not null check violated", K(var->is_not_null()), K(var_val.is_null()), K(ret));
}
OZ (package_state->set_package_var_val(var_idx, new_var_val));
OZ (package_state->set_package_var_val(var_idx, new_var_val, !need_deserialize));
if (!need_deserialize) {
OZ (package_state->update_changed_vars(var_idx));
}

View File

@ -183,7 +183,7 @@ void ObPLPackageState::reset(ObSQLSessionInfo *session_info)
cursor_allocator_.reset();
}
int ObPLPackageState::set_package_var_val(const int64_t var_idx, const ObObj &value)
int ObPLPackageState::set_package_var_val(const int64_t var_idx, const ObObj &value, bool deep_copy_complex)
{
int ret = OB_SUCCESS;
if (var_idx < 0 || var_idx >= vars_.count()) {
@ -199,7 +199,10 @@ int ObPLPackageState::set_package_var_val(const int64_t var_idx, const ObObj &va
LOG_WARN("failed to alloc memory for pacakge var", K(ret), K(buf));
}
OZ (vars_.at(var_idx).deep_copy(value, buf, value.get_deep_copy_size(), pos));
} else if (value.is_pl_extend()) {
} else if (value.is_pl_extend()
&& value.get_meta().get_extend_type() != PL_CURSOR_TYPE
&& value.get_meta().get_extend_type() != PL_REF_CURSOR_TYPE
&& deep_copy_complex) {
ObObj copy;
OZ (ObUserDefinedType::deep_copy_obj(inner_allocator_, value, copy));
OX (vars_.at(var_idx) = copy);

View File

@ -134,7 +134,7 @@ public:
common::ObIAllocator &get_pkg_allocator() { return inner_allocator_; }
common::ObIAllocator &get_pkg_cursor_allocator() { return cursor_allocator_; }
int add_package_var_val(const common::ObObj &value, ObPLType type);
int set_package_var_val(int64_t var_idx, const common::ObObj &value);
int set_package_var_val(int64_t var_idx, const common::ObObj &value, bool deep_copy_complex = true);
int get_package_var_val(int64_t var_idx, common::ObObj &value);
int update_changed_vars(int64_t var_idx);
inline bool is_package_info_changed()