[FEAT MERGE]
Co-authored-by: leftgeek <1094669802@qq.com> Co-authored-by: coolfishchen <coolfishchen@gmail.com> Co-authored-by: hy-guo <fqboyg@gmail.com>
This commit is contained in:
@ -1508,14 +1508,20 @@ int ObDmlCgService::check_upd_need_all_columns(ObLogDelUpd &op,
|
||||
need_all_columns = false;
|
||||
int64_t binlog_row_image = ObBinlogRowImage::FULL;
|
||||
ObSQLSessionInfo *session = cg_.opt_ctx_->get_session_info();
|
||||
if (OB_ISNULL(session)) {
|
||||
if (OB_ISNULL(session) || OB_ISNULL(schema_guard) || OB_ISNULL(table_schema)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null ptr", K(ret));
|
||||
LOG_WARN("unexpected null ptr", K(ret), KP(session), KP(schema_guard), KP(table_schema));
|
||||
} else if (OB_FAIL(session->get_binlog_row_image(binlog_row_image))) {
|
||||
LOG_WARN("fail to get binlog image", K(ret));
|
||||
} else if (binlog_row_image == ObBinlogRowImage::FULL || op.has_instead_of_trigger()) {
|
||||
// full mode
|
||||
need_all_columns = true;
|
||||
} else if (table_schema->has_mlog_table()) {
|
||||
need_all_columns = true;
|
||||
LOG_TRACE("update table with materialized view log, need all columns", K(table_schema->has_mlog_table()));
|
||||
} else if (table_schema->is_mlog_table()) {
|
||||
need_all_columns = true;
|
||||
LOG_TRACE("update materialized view log, need all columns", K(table_schema->is_mlog_table()));
|
||||
} else if (!is_primary_index) {
|
||||
// index_table if update PK, also need record all_columns
|
||||
if (OB_FAIL(check_has_upd_rowkey(op, table_schema, index_dml_info, is_update_pk))) {
|
||||
@ -1658,14 +1664,20 @@ int ObDmlCgService::check_del_need_all_columns(ObLogDelUpd &op,
|
||||
bool has_not_null_uk = false;
|
||||
int64_t binlog_row_image = ObBinlogRowImage::FULL;
|
||||
ObSQLSessionInfo *session = cg_.opt_ctx_->get_session_info();
|
||||
if (OB_ISNULL(session)) {
|
||||
if (OB_ISNULL(session) || OB_ISNULL(schema_guard) || OB_ISNULL(table_schema)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null ptr", K(ret));
|
||||
LOG_WARN("unexpected null ptr", K(ret), KP(session), KP(schema_guard), KP(table_schema));
|
||||
} else if (OB_FAIL(session->get_binlog_row_image(binlog_row_image))) {
|
||||
LOG_WARN("fail to get binlog image", K(ret));
|
||||
} else if (binlog_row_image == ObBinlogRowImage::FULL || op.has_instead_of_trigger()) {
|
||||
// full mode
|
||||
need_all_columns = true;
|
||||
} else if (table_schema->has_mlog_table()) {
|
||||
need_all_columns = true;
|
||||
LOG_TRACE("delete from table with materialized view log, need all columns", K(table_schema->has_mlog_table()));
|
||||
} else if (table_schema->is_mlog_table()) {
|
||||
need_all_columns = true;
|
||||
LOG_TRACE("delete from materialized view log, need all columns", K(table_schema->is_mlog_table()));
|
||||
} else if (table_schema->is_heap_table()) {
|
||||
if (OB_FAIL(table_schema->has_not_null_unique_key(*schema_guard, has_not_null_uk))) {
|
||||
LOG_WARN("fail to check whether has not null unique key", K(ret), K(table_schema->get_table_name_str()));
|
||||
|
||||
@ -843,6 +843,11 @@ int ObStaticEngineCG::generate_spec_basic(ObLogicalOperator &op,
|
||||
if (OB_SUCC(ret) && need_check_output_datum) {
|
||||
OZ(add_output_datum_check_flag(spec));
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(extract_all_mview_ids(cur_op_exprs_))) {
|
||||
LOG_WARN("fail to extract all mview ids", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
CK (OB_NOT_NULL(op.get_plan())
|
||||
&& OB_NOT_NULL(op.get_plan()->get_stmt())
|
||||
@ -862,6 +867,37 @@ int ObStaticEngineCG::generate_spec_basic(ObLogicalOperator &op,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObStaticEngineCG::extract_all_mview_ids(const ObIArray<ObRawExpr *> &exprs)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
for (int i = 0; OB_SUCC(ret) && i < exprs.count(); ++i) {
|
||||
if (OB_FAIL(extract_all_mview_ids(exprs.at(i)))) {
|
||||
LOG_WARN("extract all mview ids failed", K(ret), K(i), KPC(exprs.at(i)));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObStaticEngineCG::extract_all_mview_ids(const ObRawExpr *expr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(expr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("expr is null", K(ret), K(expr));
|
||||
} else if (ObItemType::T_FUN_SYS_LAST_REFRESH_SCN == expr->get_expr_type()) {
|
||||
if (OB_FAIL(add_var_to_array_no_dup(mview_ids_, static_cast<const ObSysFunRawExpr*>(expr)->get_mview_id()))) {
|
||||
LOG_WARN("failed to add var to array no dup", K(ret), K(mview_ids_.count()));
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; OB_SUCC(ret) && i < expr->get_param_count(); ++i) {
|
||||
if (OB_FAIL(SMART_CALL(extract_all_mview_ids(expr->get_param_expr(i))))) {
|
||||
LOG_WARN("extract all mview ids failed", K(ret), KPC(expr->get_param_expr(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObStaticEngineCG::generate_calc_exprs(
|
||||
const ObIArray<ObRawExpr *> &dep_exprs,
|
||||
const ObIArray<ObRawExpr *> &cur_exprs,
|
||||
@ -7883,6 +7919,8 @@ int ObStaticEngineCG::set_other_properties(const ObLogPlan &log_plan, ObPhysical
|
||||
LOG_WARN("set expected worker map", K(ret));
|
||||
} else if (OB_FAIL(phy_plan.set_minimal_worker_map(log_plan.get_optimizer_context().get_minimal_worker_map()))) {
|
||||
LOG_WARN("set minimal worker map", K(ret));
|
||||
} else if (OB_FAIL(phy_plan.set_mview_ids(mview_ids_))) {
|
||||
LOG_WARN("failed to set set mview_ids", K(ret), K(mview_ids_.count()));
|
||||
} else {
|
||||
if (log_plan.get_optimizer_context().is_online_ddl()) {
|
||||
if (log_plan.get_stmt()->get_table_items().count() > 0) {
|
||||
@ -7900,6 +7938,17 @@ int ObStaticEngineCG::set_other_properties(const ObLogPlan &log_plan, ObPhysical
|
||||
}
|
||||
}
|
||||
}
|
||||
if (log_plan.get_optimizer_context().get_session_info()->get_ddl_info().is_mview_complete_refresh()) {
|
||||
if (log_plan.get_stmt()->get_table_items().count() > 0) {
|
||||
const TableItem *insert_table_item = log_plan.get_stmt()->get_table_item(0);
|
||||
if (nullptr != insert_table_item) {
|
||||
int64_t ddl_task_id = 0;
|
||||
const ObOptParamHint *opt_params = &log_plan.get_stmt()->get_query_ctx()->get_global_hint().opt_params_;
|
||||
OZ(opt_params->get_integer_opt_param(ObOptParamHint::DDL_TASK_ID, ddl_task_id));
|
||||
log_plan.get_optimizer_context().get_exec_ctx()->get_table_direct_insert_ctx().set_ddl_task_id(ddl_task_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ObParamOption param_opt = log_plan.get_optimizer_context().get_global_hint().param_option_;
|
||||
bool is_exact_mode = my_session->get_enable_exact_mode();
|
||||
|
||||
@ -558,6 +558,8 @@ private:
|
||||
int generate_sort_exprs(const bool is_store_sortkey_separately, ObLogSort &op, ObSortVecSpec &spec,
|
||||
ObIArray<OrderItem> &sk_keys);
|
||||
|
||||
int extract_all_mview_ids(const ObIArray<ObRawExpr *> &exprs);
|
||||
int extract_all_mview_ids(const ObRawExpr *expr);
|
||||
private:
|
||||
struct BatchExecParamCache {
|
||||
BatchExecParamCache(ObExecParamRawExpr* expr, ObOpSpec* spec, bool is_left)
|
||||
@ -594,6 +596,7 @@ private:
|
||||
ObTscCgService tsc_cg_service_;
|
||||
uint64_t cur_cluster_version_;
|
||||
common::ObSEArray<BatchExecParamCache, 8> batch_exec_param_caches_;
|
||||
common::ObSEArray<uint64_t, 4> mview_ids_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user