diff --git a/src/sql/engine/dml/ob_trigger_handler.cpp b/src/sql/engine/dml/ob_trigger_handler.cpp index d6b2c2c695..913f5ecfd7 100644 --- a/src/sql/engine/dml/ob_trigger_handler.cpp +++ b/src/sql/engine/dml/ob_trigger_handler.cpp @@ -403,12 +403,13 @@ int TriggerHandle::calc_trigger_routine( ObArray nocopy_params; trigger_id = ObTriggerInfo::get_trigger_spec_package_id(trigger_id); bool old_flag = false; + common::ObArenaAllocator tmp_allocator(common::ObMemAttr(MTL_ID(), "TriggerExec")); CK (OB_NOT_NULL(exec_ctx.get_my_session())); OX (old_flag = exec_ctx.get_my_session()->is_for_trigger_package()); OX (exec_ctx.get_my_session()->set_for_trigger_package(true)); OV (OB_NOT_NULL(exec_ctx.get_pl_engine())); OZ (exec_ctx.get_pl_engine()->execute( - exec_ctx, exec_ctx.get_allocator(), trigger_id, routine_id, path, params, nocopy_params, result), + exec_ctx, tmp_allocator, trigger_id, routine_id, path, params, nocopy_params, result), trigger_id, routine_id, params); CK (OB_NOT_NULL(exec_ctx.get_my_session())); OZ (exec_ctx.get_my_session()->reset_all_package_state_by_dbms_session(true)); @@ -416,6 +417,18 @@ int TriggerHandle::calc_trigger_routine( // whether `ret == OB_SUCCESS`, need to restore flag exec_ctx.get_my_session()->set_for_trigger_package(old_flag); } + if (OB_SUCC(ret)) { + bool copy_out_param = lib::is_oracle_mode() ? + (ROUTINE_IDX_BEFORE_ROW == routine_id) : (ROUTINE_IDX_BEFORE_ROW_MYSQL == routine_id); + if (copy_out_param) { + CK (2 == params.count()); + if (OB_SUCC(ret)) { + pl::ObPLRecord *new_record = reinterpret_cast(params.at(1).get_ext()); + CK (OB_NOT_NULL(new_record)); + OZ (new_record->deep_copy(*new_record, exec_ctx.get_allocator())); + } + } + } return ret; }