fix materialized view bug

This commit is contained in:
chimyue 2024-11-05 04:45:07 +00:00 committed by ob-robot
parent 8c7deb9fcf
commit d0d1d1613d
4 changed files with 23 additions and 6 deletions

View File

@ -2766,6 +2766,7 @@ int ObDMLResolver::resolve_basic_column_item(const TableItem &table_item,
include_hidden = true;
if (T_NONE_SCOPE == params_.hidden_column_scope_) {
params_.hidden_column_scope_ = current_scope_;
params_.hidden_column_name_ = OB_HIDDEN_PK_INCREMENT_COLUMN_NAME;
}
}
}
@ -13690,6 +13691,12 @@ int ObDMLResolver::resolve_old_new_pseudo_column(const ObQualifiedName &q_name,
real_ref_expr = pseudo_column_expr;
LOG_DEBUG("old_new_expr build success", K(*pseudo_column_expr));
}
if (OB_SUCC(ret) && T_NONE_SCOPE == params_.hidden_column_scope_
&& !(params_.is_for_rt_mv_ || session_info_->get_ddl_info().is_major_refreshing_mview())) {
params_.hidden_column_scope_ = current_scope_;
params_.hidden_column_name_ = OB_MLOG_OLD_NEW_COLUMN_NAME;
}
return ret;
}

View File

@ -240,12 +240,17 @@ int ObQueryHint::check_and_set_params_from_hint(const ObResolverParams &params,
OB_FAIL(global_hint_.opt_params_.has_enable_opt_param(ObOptParamHint::OptParamType::HIDDEN_COLUMN_VISIBLE, has_enable_param))) {
LOG_WARN("failed to check has enable opt param", K(ret));
} else if (OB_UNLIKELY(T_NONE_SCOPE != params.hidden_column_scope_ && !has_enable_param)) {
ret = OB_ERR_BAD_FIELD_ERROR;
LOG_WARN("hidden columns not allowed", K(ret));
ObString column_name(OB_HIDDEN_PK_INCREMENT_COLUMN_NAME);
ObString scope_name = ObString::make_string(get_scope_name(params.hidden_column_scope_));
LOG_USER_ERROR(OB_ERR_BAD_FIELD_ERROR, column_name.length(), column_name.ptr(),
scope_name.length(), scope_name.ptr());
if (OB_ISNULL(params.hidden_column_name_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected null", K(ret), K(params.hidden_column_scope_), K(params.hidden_column_name_));
} else {
ret = OB_ERR_BAD_FIELD_ERROR;
LOG_WARN("hidden columns not allowed", K(ret));
ObString column_name(params.hidden_column_name_);
ObString scope_name = ObString::make_string(get_scope_name(params.hidden_column_scope_));
LOG_USER_ERROR(OB_ERR_BAD_FIELD_ERROR, column_name.length(), column_name.ptr(),
scope_name.length(), scope_name.ptr());
}
} else if (OB_FAIL(check_ddl_schema_version_from_hint(stmt))) {
LOG_WARN("failed to check ddl schema version", K(ret));
} else {

View File

@ -225,6 +225,9 @@ int ObMVChecker::check_mv_table_type_valid(const ObSelectStmt &stmt, bool &is_va
} else if (OB_NOT_NULL(table->flashback_query_expr_)) {
is_valid = false;
append_fast_refreshable_note("flashback query not support");
} else if (OB_UNLIKELY(!table->part_ids_.empty())) {
is_valid = false;
append_fast_refreshable_note("define mview use table with partition hint not support");
}
}
}

View File

@ -361,6 +361,7 @@ struct ObResolverParams
tg_timing_event_(-1),
is_column_ref_(true),
hidden_column_scope_(T_NONE_SCOPE),
hidden_column_name_(NULL),
outline_parse_result_(NULL),
is_execute_call_stmt_(false),
enable_res_map_(false),
@ -431,6 +432,7 @@ public:
int64_t tg_timing_event_; // mysql mode, trigger的触发时机和类型
bool is_column_ref_; // used to mark normal column ref
ObStmtScope hidden_column_scope_; // record scope for first hidden column which need check hidden_column_visable in opt_param hint
const char *hidden_column_name_; // record column name for first hidden column which need check hidden_column_visable in opt_param hint
ParseResult *outline_parse_result_;
bool is_execute_call_stmt_;
bool enable_res_map_;