[to #45264327]move the instead of trigger code to das
This commit is contained in:
parent
41509ff30d
commit
cbeae2bffc
@ -1917,7 +1917,6 @@ int ObStaticEngineCG::generate_insert_with_das(ObLogInsert &op, ObTableInsertSpe
|
||||
spec.use_dist_das_ = op.is_multi_part_dml();
|
||||
spec.gi_above_ = op.is_gi_above() && !spec.use_dist_das_;
|
||||
spec.is_returning_ = op.is_returning();
|
||||
spec.has_instead_of_trigger_ = op.has_instead_of_trigger();
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < index_dml_infos.count(); ++i) {
|
||||
@ -1928,7 +1927,11 @@ int ObStaticEngineCG::generate_insert_with_das(ObLogInsert &op, ObTableInsertSpe
|
||||
LOG_WARN("index dml info is null", K(ret));
|
||||
} else if (OB_FAIL(dml_cg_service_.generate_insert_ctdef(op, *index_dml_info, ins_ctdef))) {
|
||||
LOG_WARN("generate insert ctdef failed", K(ret));
|
||||
} else if (OB_ISNULL(ins_ctdef)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("ins_ctdef is null", K(ret));
|
||||
} else {
|
||||
ins_ctdef->has_instead_of_trigger_ = op.has_instead_of_trigger();
|
||||
spec.ins_ctdefs_.at(0).at(i) = ins_ctdef;
|
||||
}
|
||||
} // for index_dml_infos end
|
||||
@ -1994,7 +1997,6 @@ int ObStaticEngineCG::generate_delete_with_das(ObLogDelete &op, ObTableDeleteSpe
|
||||
spec.use_dist_das_ = op.is_multi_part_dml();
|
||||
spec.gi_above_ = op.is_gi_above() && !spec.use_dist_das_;
|
||||
spec.is_returning_ = op.is_returning();
|
||||
spec.has_instead_of_trigger_ = op.has_instead_of_trigger();
|
||||
if (OB_FAIL(spec.del_ctdefs_.allocate_array(phy_plan_->get_allocator(),
|
||||
delete_table_list.count()))) {
|
||||
LOG_WARN("allocate delete ctdef array failed", K(ret));
|
||||
@ -2025,7 +2027,11 @@ int ObStaticEngineCG::generate_delete_with_das(ObLogDelete &op, ObTableDeleteSpe
|
||||
LOG_WARN("index dml info is null", K(ret));
|
||||
} else if (OB_FAIL(dml_cg_service_.generate_delete_ctdef(op, *index_dml_info, del_ctdef))) {
|
||||
LOG_WARN("generate delete ctdef failed", K(ret));
|
||||
} else if (OB_ISNULL(del_ctdef)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("del_ctdef is null", K(ret));
|
||||
} else {
|
||||
del_ctdef->has_instead_of_trigger_ = op.has_instead_of_trigger();
|
||||
ctdefs.at(j) = del_ctdef;
|
||||
}
|
||||
} // for index_dml_infos end
|
||||
@ -2117,7 +2123,6 @@ int ObStaticEngineCG::generate_update_with_das(ObLogUpdate &op, ObTableUpdateSpe
|
||||
spec.use_dist_das_ = op.is_multi_part_dml();
|
||||
spec.gi_above_ = op.is_gi_above() && !spec.use_dist_das_;
|
||||
spec.is_returning_ = op.is_returning();
|
||||
spec.has_instead_of_trigger_ = op.has_instead_of_trigger();
|
||||
if (OB_FAIL(spec.upd_ctdefs_.allocate_array(phy_plan_->get_allocator(),
|
||||
table_list.count()))) {
|
||||
LOG_WARN("allocate update ctdef array failed", K(ret), K(table_list));
|
||||
@ -2145,7 +2150,11 @@ int ObStaticEngineCG::generate_update_with_das(ObLogUpdate &op, ObTableUpdateSpe
|
||||
LOG_WARN("index dml info is null", K(ret));
|
||||
} else if (OB_FAIL(dml_cg_service_.generate_update_ctdef(op, *index_dml_info, upd_ctdef))) {
|
||||
LOG_WARN("generate update ctdef failed", K(ret));
|
||||
} else if (OB_ISNULL(upd_ctdef)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("upd_ctdef is null", K(ret));
|
||||
} else {
|
||||
upd_ctdef->has_instead_of_trigger_ = op.has_instead_of_trigger();
|
||||
ctdefs.at(j) = upd_ctdef;
|
||||
}
|
||||
} // for index_dml_infos end
|
||||
|
@ -203,7 +203,8 @@ OB_SERIALIZE_MEMBER(ObDMLBaseCtDef,
|
||||
error_logging_ctdef_,
|
||||
view_check_exprs_,
|
||||
is_primary_index_,
|
||||
is_heap_table_);
|
||||
is_heap_table_,
|
||||
has_instead_of_trigger_);
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObMultiInsCtDef,
|
||||
calc_part_id_expr_,
|
||||
|
@ -372,7 +372,8 @@ public:
|
||||
K_(new_row),
|
||||
K_(view_check_exprs),
|
||||
K_(is_primary_index),
|
||||
K_(is_heap_table));
|
||||
K_(is_heap_table),
|
||||
K_(has_instead_of_trigger));
|
||||
|
||||
ObDMLOpType dml_type_;
|
||||
ExprFixedArray check_cst_exprs_;
|
||||
@ -393,6 +394,7 @@ public:
|
||||
ExprFixedArray view_check_exprs_;
|
||||
bool is_primary_index_;
|
||||
bool is_heap_table_;
|
||||
bool has_instead_of_trigger_;
|
||||
protected:
|
||||
ObDMLBaseCtDef(common::ObIAllocator &alloc,
|
||||
ObDASDMLBaseCtDef &das_base_ctdef,
|
||||
@ -408,7 +410,8 @@ protected:
|
||||
error_logging_ctdef_(alloc),
|
||||
view_check_exprs_(alloc),
|
||||
is_primary_index_(false),
|
||||
is_heap_table_(false)
|
||||
is_heap_table_(false),
|
||||
has_instead_of_trigger_(false)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
@ -385,58 +385,10 @@ int ObDMLService::process_after_stmt_trigger(const ObDMLBaseCtDef &dml_ctdef,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDMLService::process_instead_of_trigger_delete(
|
||||
const ObDelCtDef &del_ctdef,
|
||||
ObDelRtDef &del_rtdef,
|
||||
ObTableModifyOp &dml_op)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(TriggerHandle::init_param_old_row(
|
||||
dml_op.get_eval_ctx(), del_ctdef.trig_ctdef_, del_rtdef.trig_rtdef_))) {
|
||||
LOG_WARN("failed to handle before trigger", K(ret));
|
||||
} else if (OB_FAIL(TriggerHandle::do_handle_before_row(
|
||||
dml_op, del_ctdef.das_base_ctdef_, del_ctdef.trig_ctdef_, del_rtdef.trig_rtdef_))) {
|
||||
LOG_WARN("failed to handle before trigger", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDMLService::process_instead_of_trigger_update(
|
||||
const ObUpdCtDef &upd_ctdef,
|
||||
ObUpdRtDef &upd_rtdef,
|
||||
ObTableModifyOp &dml_op)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(TriggerHandle::init_param_rows(
|
||||
dml_op.get_eval_ctx(), upd_ctdef.trig_ctdef_, upd_rtdef.trig_rtdef_))) {
|
||||
LOG_WARN("failed to handle before trigger", K(ret));
|
||||
} else if (OB_FAIL(TriggerHandle::do_handle_before_row(
|
||||
dml_op, upd_ctdef.das_base_ctdef_, upd_ctdef.trig_ctdef_, upd_rtdef.trig_rtdef_))) {
|
||||
LOG_WARN("failed to handle before trigger", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDMLService::process_instead_of_trigger_insert(
|
||||
const ObInsCtDef &ins_ctdef,
|
||||
ObInsRtDef &ins_rtdef,
|
||||
ObTableModifyOp &dml_op)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(TriggerHandle::init_param_new_row(
|
||||
dml_op.get_eval_ctx(), ins_ctdef.trig_ctdef_, ins_rtdef.trig_rtdef_))) {
|
||||
LOG_WARN("failed to handle before trigger", K(ret));
|
||||
} else if (OB_FAIL(TriggerHandle::do_handle_before_row(
|
||||
dml_op, ins_ctdef.das_base_ctdef_, ins_ctdef.trig_ctdef_, ins_rtdef.trig_rtdef_))) {
|
||||
LOG_WARN("failed to handle before trigger", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDMLService::init_heap_table_pk_for_ins(const ObInsCtDef &ins_ctdef, ObEvalCtx &eval_ctx)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (ins_ctdef.is_primary_index_ && ins_ctdef.is_heap_table_) {
|
||||
if (ins_ctdef.is_primary_index_ && ins_ctdef.is_heap_table_ && !ins_ctdef.has_instead_of_trigger_) {
|
||||
ObExpr *auto_inc_expr = ins_ctdef.new_row_.at(0);
|
||||
if (OB_ISNULL(auto_inc_expr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -465,7 +417,7 @@ int ObDMLService::process_insert_row(const ObInsCtDef &ins_ctdef,
|
||||
ObEvalCtx &eval_ctx = dml_op.get_eval_ctx();
|
||||
uint64_t ref_table_id = ins_ctdef.das_base_ctdef_.index_tid_;
|
||||
ObSQLSessionInfo *my_session = NULL;
|
||||
|
||||
bool has_instead_of_trg = ins_ctdef.has_instead_of_trigger_;
|
||||
//first, check insert value whether matched column type
|
||||
if (OB_FAIL(check_column_type(ins_ctdef.new_row_,
|
||||
ins_rtdef.cur_row_num_,
|
||||
@ -483,6 +435,10 @@ int ObDMLService::process_insert_row(const ObInsCtDef &ins_ctdef,
|
||||
} else if (OB_FAIL(TriggerHandle::do_handle_before_row(
|
||||
dml_op, ins_ctdef.das_base_ctdef_, ins_ctdef.trig_ctdef_, ins_rtdef.trig_rtdef_))) {
|
||||
LOG_WARN("failed to handle before trigger", K(ret));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (has_instead_of_trg) {
|
||||
is_skipped = true;
|
||||
} else if (OB_FAIL(check_row_null(ins_ctdef.new_row_,
|
||||
dml_op.get_eval_ctx(),
|
||||
ins_rtdef.cur_row_num_,
|
||||
@ -514,7 +470,7 @@ int ObDMLService::process_insert_row(const ObInsCtDef &ins_ctdef,
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret) && dml_op.is_error_logging_ && should_catch_err(ret)) {
|
||||
if (OB_FAIL(ret) && dml_op.is_error_logging_ && should_catch_err(ret) && !has_instead_of_trg) {
|
||||
dml_op.err_log_rt_def_.first_err_ret_ = ret;
|
||||
// cover the err_ret by design
|
||||
ret = OB_SUCCESS;
|
||||
@ -568,13 +524,14 @@ int ObDMLService::process_delete_row(const ObDelCtDef &del_ctdef,
|
||||
if (del_ctdef.is_primary_index_) {
|
||||
uint64_t ref_table_id = del_ctdef.das_base_ctdef_.index_tid_;
|
||||
ObSQLSessionInfo *my_session = NULL;
|
||||
bool has_instead_of_trg = del_ctdef.has_instead_of_trigger_;
|
||||
if (OB_ISNULL(my_session = dml_op.get_exec_ctx().get_my_session())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("session is NULL", K(ret));
|
||||
} else if (OB_FAIL(check_nested_sql_legality(dml_op.get_exec_ctx(), del_ctdef.das_ctdef_.index_tid_))) {
|
||||
LOG_WARN("failed to check stmt table", K(ret), K(ref_table_id));
|
||||
}
|
||||
if (OB_SUCC(ret) && del_ctdef.need_check_filter_null_) {
|
||||
if (OB_SUCC(ret) && del_ctdef.need_check_filter_null_ && !has_instead_of_trg) {
|
||||
bool is_null = false;
|
||||
if (OB_FAIL(check_rowkey_is_null(del_ctdef.old_row_,
|
||||
del_ctdef.das_ctdef_.rowkey_cnt_,
|
||||
@ -585,7 +542,7 @@ int ObDMLService::process_delete_row(const ObDelCtDef &del_ctdef,
|
||||
is_skipped = true;
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && !is_skipped) {
|
||||
if (OB_SUCC(ret) && !is_skipped && !has_instead_of_trg) {
|
||||
bool is_distinct = false;
|
||||
if (OB_FAIL(check_rowkey_whether_distinct(del_ctdef.distinct_key_,
|
||||
del_ctdef.distinct_key_.count(),
|
||||
@ -601,7 +558,7 @@ int ObDMLService::process_delete_row(const ObDelCtDef &del_ctdef,
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && !is_skipped) {
|
||||
if (OB_FAIL(ForeignKeyHandle::do_handle(dml_op, del_ctdef, del_rtdef))) {
|
||||
if (!has_instead_of_trg && OB_FAIL(ForeignKeyHandle::do_handle(dml_op, del_ctdef, del_rtdef))) {
|
||||
LOG_WARN("do handle old row for delete op failed", K(ret), K(del_ctdef), K(del_rtdef));
|
||||
} else if (OB_FAIL(TriggerHandle::init_param_old_row(
|
||||
dml_op.get_eval_ctx(), del_ctdef.trig_ctdef_, del_rtdef.trig_rtdef_))) {
|
||||
@ -612,10 +569,12 @@ int ObDMLService::process_delete_row(const ObDelCtDef &del_ctdef,
|
||||
} else if (OB_SUCC(ret) && OB_FAIL(TriggerHandle::do_handle_after_row(
|
||||
dml_op, del_ctdef.trig_ctdef_, del_rtdef.trig_rtdef_, ObTriggerEvents::get_delete_event()))) {
|
||||
LOG_WARN("failed to handle before trigger", K(ret));
|
||||
} else if (has_instead_of_trg) {
|
||||
is_skipped = true;
|
||||
}
|
||||
}
|
||||
// here only catch foreign key execption
|
||||
if (OB_FAIL(ret) && dml_op.is_error_logging_ && should_catch_err(ret)) {
|
||||
if (OB_FAIL(ret) && dml_op.is_error_logging_ && should_catch_err(ret) && !has_instead_of_trg) {
|
||||
dml_op.err_log_rt_def_.first_err_ret_ = ret;
|
||||
}
|
||||
|
||||
@ -633,6 +592,7 @@ int ObDMLService::process_update_row(const ObUpdCtDef &upd_ctdef,
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
is_skipped = false;
|
||||
bool has_instead_of_trg = upd_ctdef.has_instead_of_trigger_;
|
||||
if (upd_ctdef.is_primary_index_) {
|
||||
uint64_t ref_table_id = upd_ctdef.das_base_ctdef_.index_tid_;
|
||||
ObSQLSessionInfo *my_session = NULL;
|
||||
@ -641,7 +601,7 @@ int ObDMLService::process_update_row(const ObUpdCtDef &upd_ctdef,
|
||||
LOG_WARN("fail to copy heap table hidden pk", K(ret), K(upd_ctdef));
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret) && upd_ctdef.need_check_filter_null_) {
|
||||
if (OB_SUCC(ret) && upd_ctdef.need_check_filter_null_ && !has_instead_of_trg) {
|
||||
bool is_null = false;
|
||||
if (OB_FAIL(check_rowkey_is_null(upd_ctdef.old_row_,
|
||||
upd_ctdef.dupd_ctdef_.rowkey_cnt_,
|
||||
@ -652,7 +612,7 @@ int ObDMLService::process_update_row(const ObUpdCtDef &upd_ctdef,
|
||||
is_skipped = true;
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && !is_skipped) {
|
||||
if (OB_SUCC(ret) && !is_skipped && !has_instead_of_trg) {
|
||||
bool is_distinct = false;
|
||||
if (OB_FAIL(check_rowkey_whether_distinct(upd_ctdef.distinct_key_,
|
||||
upd_ctdef.distinct_key_.count(),
|
||||
@ -686,12 +646,16 @@ int ObDMLService::process_update_row(const ObUpdCtDef &upd_ctdef,
|
||||
} else if (OB_FAIL(TriggerHandle::do_handle_before_row(
|
||||
dml_op, upd_ctdef.das_base_ctdef_, upd_ctdef.trig_ctdef_, upd_rtdef.trig_rtdef_))) {
|
||||
LOG_WARN("failed to handle before trigger", K(ret));
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (has_instead_of_trg) {
|
||||
is_skipped = true;
|
||||
} else if (OB_FAIL(check_row_null(upd_ctdef.new_row_,
|
||||
dml_op.get_eval_ctx(),
|
||||
upd_rtdef.cur_row_num_,
|
||||
upd_ctdef.assign_columns_,
|
||||
upd_ctdef.dupd_ctdef_.is_ignore_,
|
||||
dml_op))) {
|
||||
dml_op.get_eval_ctx(),
|
||||
upd_rtdef.cur_row_num_,
|
||||
upd_ctdef.assign_columns_,
|
||||
upd_ctdef.dupd_ctdef_.is_ignore_,
|
||||
dml_op))) {
|
||||
LOG_WARN("check row null failed", K(ret), K(upd_ctdef), K(upd_rtdef));
|
||||
} else if (OB_FAIL(check_row_whether_changed(upd_ctdef, upd_rtdef, dml_op.get_eval_ctx()))) {
|
||||
LOG_WARN("check row whether changed failed", K(ret), K(upd_ctdef), K(upd_rtdef));
|
||||
@ -724,7 +688,7 @@ int ObDMLService::process_update_row(const ObUpdCtDef &upd_ctdef,
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret) && dml_op.is_error_logging_ && should_catch_err(ret)) {
|
||||
if (OB_FAIL(ret) && dml_op.is_error_logging_ && should_catch_err(ret) && !has_instead_of_trg) {
|
||||
dml_op.err_log_rt_def_.first_err_ret_ = ret;
|
||||
// cover the err_ret by design
|
||||
ret = OB_SUCCESS;
|
||||
|
@ -65,15 +65,6 @@ public:
|
||||
ObDMLBaseRtDef &dml_rtdef,
|
||||
ObDMLRtCtx &dml_rtctx,
|
||||
const ObDmlEventType &dml_event);
|
||||
static int process_instead_of_trigger_insert(const ObInsCtDef &ins_ctdef,
|
||||
ObInsRtDef &ins_rtdef,
|
||||
ObTableModifyOp &dml_op);
|
||||
static int process_instead_of_trigger_delete(const ObDelCtDef &del_ctdef,
|
||||
ObDelRtDef &del_rtdef,
|
||||
ObTableModifyOp &dml_op);
|
||||
static int process_instead_of_trigger_update(const ObUpdCtDef &upd_ctdef,
|
||||
ObUpdRtDef &upd_rtdef,
|
||||
ObTableModifyOp &dml_op);
|
||||
static int process_delete_row(const ObDelCtDef &del_ctdef,
|
||||
ObDelRtDef &del_rtdef,
|
||||
bool &is_skipped,
|
||||
|
@ -125,32 +125,6 @@ int ObTableDeleteOp::inner_open()
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int ObTableDeleteOp::do_instead_of_trigger_delete()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObPhysicalPlanCtx *plan_ctx = GET_PHY_PLAN_CTX(ctx_);
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < MY_SPEC.del_ctdefs_.count(); ++i) {
|
||||
const ObTableDeleteSpec::DelCtDefArray &ctdefs = MY_SPEC.del_ctdefs_.at(i);
|
||||
if (0 < del_rtdefs_.count()) {
|
||||
// pdml del_rtdefs_ maybe empty
|
||||
DelRtDefArray &rtdefs = del_rtdefs_.at(i);
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < ctdefs.count(); ++j) {
|
||||
const ObDelCtDef &del_ctdef = *ctdefs.at(j);
|
||||
ObDelRtDef &del_rtdef = rtdefs.at(j);
|
||||
if (del_ctdef.is_primary_index_) {
|
||||
if (OB_FAIL(ObDMLService::process_instead_of_trigger_delete(del_ctdef, del_rtdef, *this))) {
|
||||
LOG_WARN("failed to process instead of trigger", K(ret));
|
||||
} else {
|
||||
plan_ctx->add_affected_rows(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableDeleteOp::inner_get_next_row()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -167,10 +141,6 @@ int ObTableDeleteOp::inner_get_next_row()
|
||||
} else {
|
||||
iter_end_ = true;
|
||||
}
|
||||
} else if (MY_SPEC.has_instead_of_trigger_) {
|
||||
if (OB_FAIL(do_instead_of_trigger_delete())) {
|
||||
LOG_WARN("failed to do instead of trigger", K(ret));
|
||||
}
|
||||
} else if (OB_FAIL(delete_row_to_das())) {
|
||||
LOG_WARN("delete row to das failed", K(ret));
|
||||
} else if (is_error_logging_ && err_log_rt_def_.first_err_ret_ != OB_SUCCESS) {
|
||||
@ -181,7 +151,7 @@ int ObTableDeleteOp::inner_get_next_row()
|
||||
}
|
||||
}
|
||||
if (OB_ITER_END == ret) {
|
||||
if (!MY_SPEC.has_instead_of_trigger_ && OB_FAIL(del_rows_post_proc())) {
|
||||
if (!MY_SPEC.del_ctdefs_.at(0).at(0)->has_instead_of_trigger_ && OB_FAIL(del_rows_post_proc())) {
|
||||
LOG_WARN("do delete rows post process failed", K(ret));
|
||||
} else {
|
||||
//can not overwrite the original error code
|
||||
|
@ -93,7 +93,6 @@ protected:
|
||||
int open_table_for_each();
|
||||
int close_table_for_each();
|
||||
int get_next_row_from_child();
|
||||
int do_instead_of_trigger_delete();
|
||||
int check_delete_affected_row();
|
||||
protected:
|
||||
DelRtDef2DArray del_rtdefs_; //see the comment of DelCtDef2DArray
|
||||
|
@ -406,29 +406,6 @@ int ObTableInsertOp::get_next_row_from_child()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableInsertOp::do_instead_of_trigger_insert()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObPhysicalPlanCtx *plan_ctx = GET_PHY_PLAN_CTX(ctx_);
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < MY_SPEC.ins_ctdefs_.count(); ++i) {
|
||||
const ObTableInsertSpec::InsCtDefArray &ctdefs = MY_SPEC.ins_ctdefs_.at(i);
|
||||
InsRtDefArray &rtdefs = ins_rtdefs_.at(i);
|
||||
// insert each table with fetched row
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < ctdefs.count(); ++j) {
|
||||
const ObInsCtDef &ins_ctdef = *(ctdefs.at(j));
|
||||
ObInsRtDef &ins_rtdef = rtdefs.at(j);
|
||||
if (ins_ctdef.is_primary_index_) {
|
||||
if (OB_FAIL(ObDMLService::process_instead_of_trigger_insert(ins_ctdef, ins_rtdef, *this))) {
|
||||
LOG_WARN("failed to process instead of trigger", K(ret));
|
||||
} else {
|
||||
plan_ctx->add_affected_rows(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableInsertOp::inner_get_next_row()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -445,10 +422,6 @@ int ObTableInsertOp::inner_get_next_row()
|
||||
} else {
|
||||
iter_end_ = true;
|
||||
}
|
||||
} else if (MY_SPEC.has_instead_of_trigger_) {
|
||||
if (OB_FAIL(do_instead_of_trigger_insert())) {
|
||||
LOG_WARN("failed to do instead of trigger", K(ret));
|
||||
}
|
||||
} else if (OB_FAIL(insert_row_to_das())) {
|
||||
LOG_WARN("insert row to das failed", K(ret));
|
||||
} else if (is_error_logging_ && err_log_rt_def_.first_err_ret_ != OB_SUCCESS) {
|
||||
@ -462,7 +435,7 @@ int ObTableInsertOp::inner_get_next_row()
|
||||
}
|
||||
|
||||
if (OB_ITER_END == ret) {
|
||||
if (!MY_SPEC.has_instead_of_trigger_ && OB_FAIL(ins_rows_post_proc())) {
|
||||
if (!MY_SPEC.ins_ctdefs_.at(0).at(0)->has_instead_of_trigger_ && OB_FAIL(ins_rows_post_proc())) {
|
||||
LOG_WARN("do insert rows post process failed", K(ret));
|
||||
} else {
|
||||
ret = OB_ITER_END;
|
||||
|
@ -89,7 +89,6 @@ protected:
|
||||
ObDASTabletLoc *&tablet_loc);
|
||||
int open_table_for_each();
|
||||
int get_next_row_from_child();
|
||||
int do_instead_of_trigger_insert();
|
||||
int close_table_for_each();
|
||||
|
||||
int check_insert_affected_row();
|
||||
|
@ -93,7 +93,6 @@ public:
|
||||
void set_table_location_uncertain(bool v) { table_location_uncertain_ = v; }
|
||||
bool is_table_location_uncertain() const { return table_location_uncertain_; }
|
||||
inline bool use_dist_das() const { return use_dist_das_; }
|
||||
inline bool has_instead_of_trigger() const { return has_instead_of_trigger_; }
|
||||
public:
|
||||
// Expr frame info for partial expr serialization. (serialize is not need for it self)
|
||||
ObExprFrameInfo *expr_frame_info_;
|
||||
@ -107,7 +106,7 @@ public:
|
||||
uint64_t is_pdml_index_maintain_ : 1; // 表示当前dml算子是否是pdml中用于维护索引操作的算子(index maintain)
|
||||
uint64_t table_location_uncertain_ : 1; // 目标访问分区位置不确定,需要全表访问
|
||||
uint64_t use_dist_das_ : 1;
|
||||
uint64_t has_instead_of_trigger_ : 1;
|
||||
uint64_t has_instead_of_trigger_ : 1; // abandoned, don't use again
|
||||
uint64_t is_pdml_update_split_ : 1; // 标记delete, insert op是否由update拆分而来
|
||||
uint64_t reserved_ : 56;
|
||||
};
|
||||
|
@ -170,32 +170,6 @@ int ObTableUpdateOp::inner_switch_iterator()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableUpdateOp::do_instead_of_trigger_update()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObPhysicalPlanCtx *plan_ctx = GET_PHY_PLAN_CTX(ctx_);
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < MY_SPEC.upd_ctdefs_.count(); ++i) {
|
||||
const ObTableUpdateSpec::UpdCtDefArray &ctdefs = MY_SPEC.upd_ctdefs_.at(i);
|
||||
if (0 < upd_rtdefs_.count()) {
|
||||
// pdml upd_rtdefs_ maybe empty
|
||||
UpdRtDefArray &rtdefs = upd_rtdefs_.at(i);
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < ctdefs.count(); ++j) {
|
||||
const ObUpdCtDef &upd_ctdef = *ctdefs.at(j);
|
||||
ObUpdRtDef &upd_rtdef = rtdefs.at(j);
|
||||
if (upd_ctdef.is_primary_index_) {
|
||||
if (OB_FAIL(ObDMLService::process_instead_of_trigger_update(upd_ctdef, upd_rtdef, *this))) {
|
||||
LOG_WARN("failed to process instead of trigger", K(ret));
|
||||
} else {
|
||||
plan_ctx->add_affected_rows(1);
|
||||
plan_ctx->add_row_matched_count(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableUpdateOp::inner_get_next_row()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -212,10 +186,6 @@ int ObTableUpdateOp::inner_get_next_row()
|
||||
} else {
|
||||
iter_end_ = true;
|
||||
}
|
||||
} else if (MY_SPEC.has_instead_of_trigger_) {
|
||||
if (OB_FAIL(do_instead_of_trigger_update())) {
|
||||
LOG_WARN("failed to do instead of trigger", K(ret));
|
||||
}
|
||||
} else if (OB_FAIL(update_row_to_das())) {
|
||||
LOG_WARN("update row to das failed", K(ret));
|
||||
} else if (is_error_logging_ && err_log_rt_def_.first_err_ret_ != OB_SUCCESS) {
|
||||
@ -228,7 +198,7 @@ int ObTableUpdateOp::inner_get_next_row()
|
||||
}
|
||||
}
|
||||
if (OB_ITER_END == ret) {
|
||||
if (!MY_SPEC.has_instead_of_trigger_ && OB_FAIL(upd_rows_post_proc())) {
|
||||
if (!MY_SPEC.upd_ctdefs_.at(0).at(0)->has_instead_of_trigger_ && OB_FAIL(upd_rows_post_proc())) {
|
||||
LOG_WARN("do update rows post process failed", K(ret));
|
||||
} else {
|
||||
//can not overwrite the original error code
|
||||
@ -380,7 +350,6 @@ OB_INLINE int ObTableUpdateOp::calc_tablet_loc(const ObUpdCtDef &upd_ctdef,
|
||||
OB_INLINE int ObTableUpdateOp::update_row_to_das()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < MY_SPEC.upd_ctdefs_.count(); ++i) {
|
||||
const ObTableUpdateSpec::UpdCtDefArray &ctdefs = MY_SPEC.upd_ctdefs_.at(i);
|
||||
UpdRtDefArray &rtdefs = upd_rtdefs_.at(i);
|
||||
|
@ -107,7 +107,6 @@ protected:
|
||||
int open_table_for_each();
|
||||
int close_table_for_each();
|
||||
int get_next_row_from_child();
|
||||
int do_instead_of_trigger_update();
|
||||
int check_update_affected_row();
|
||||
protected:
|
||||
UpdRtDef2DArray upd_rtdefs_; //see the comment of UpdCtDef2DArray
|
||||
|
@ -532,12 +532,12 @@ int TriggerHandle::do_handle_before_row(
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("trigger row point params is not init", K(ret));
|
||||
} else {
|
||||
const ObTableModifySpec &modify_spec = static_cast<const ObTableModifySpec&>(dml_op.get_spec());
|
||||
if (OB_FAIL(calc_before_row(dml_op, trig_rtdef, tg_arg.get_trigger_id()))) {
|
||||
LOG_WARN("failed to calc before row", K(ret));
|
||||
} else if ((ObTriggerEvents::is_update_event(tg_event) ||
|
||||
ObTriggerEvents::is_insert_event(tg_event))) {
|
||||
const ObTableModifySpec &modify_spec = static_cast<const ObTableModifySpec&>(dml_op.get_spec());
|
||||
if (!modify_spec.has_instead_of_trigger_ &&
|
||||
if (!trig_ctdef.all_tm_points_.has_instead_row() &&
|
||||
OB_FAIL(check_and_update_new_row(&dml_op,
|
||||
trig_ctdef.trig_col_info_,
|
||||
dml_op.get_eval_ctx(),
|
||||
@ -547,6 +547,13 @@ int TriggerHandle::do_handle_before_row(
|
||||
LOG_WARN("failed to check updated new row", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && trig_ctdef.all_tm_points_.has_instead_row()) {
|
||||
GET_PHY_PLAN_CTX(dml_op.get_exec_ctx())->add_affected_rows(1);
|
||||
if (ObTriggerEvents::is_update_event(tg_event)) {
|
||||
GET_PHY_PLAN_CTX(dml_op.get_exec_ctx())->add_row_matched_count(1);
|
||||
GET_PHY_PLAN_CTX(dml_op.get_exec_ctx())->add_row_duplicated_count(1);
|
||||
}
|
||||
}
|
||||
LOG_DEBUG("TRIGGER calc before row", K(need_fire), K(i));
|
||||
}
|
||||
}
|
||||
|
@ -278,6 +278,7 @@ int ObTriggerResolver::resolve_instead_dml_trigger(const ParseNode &parse_node,
|
||||
OV (OB_ISNULL(parse_node.children_[2]), OB_ERR_WHEN_CLAUSE_IN_TRI);
|
||||
OV (OB_NOT_NULL(parse_node.children_[3])); // trigger body.
|
||||
OX (trigger_arg.trigger_info_.add_before_row()); // instead of trigger is always before row.
|
||||
OX (trigger_arg.trigger_info_.add_instead_row());
|
||||
OZ (resolve_dml_event_option(*parse_node.children_[0], trigger_arg));
|
||||
OZ (resolve_reference_names(parse_node.children_[1], trigger_arg));
|
||||
OZ (resolve_trigger_status(parse_node.int16_values_[1], trigger_arg));
|
||||
|
Loading…
x
Reference in New Issue
Block a user