[CP] fix range conds expr contain generate column cause 4016
This commit is contained in:
parent
6c50451c43
commit
aaaaa353ae
@ -10609,6 +10609,8 @@ int ObLogPlan::replace_generate_column_exprs(ObLogicalOperator *op)
|
||||
LOG_WARN("failed to generate replace generated tsc expr", K(ret));
|
||||
} else if (OB_FAIL(scan_op->generate_ddl_output_column_ids())) {
|
||||
LOG_WARN("fail to generate ddl output column ids");
|
||||
} else if (OB_FAIL(scan_op->copy_gen_col_range_exprs())) {
|
||||
LOG_WARN("fail to copy gen col range exprs", K(ret));
|
||||
} else if (OB_FAIL(scan_op->replace_gen_col_op_exprs(gen_col_replacer_))) {
|
||||
LOG_WARN("failed to replace generated tsc expr", K(ret));
|
||||
}
|
||||
@ -10730,7 +10732,7 @@ int ObLogPlan::generate_tsc_replace_exprs_pair(ObLogTableScan *op)
|
||||
if (OB_ISNULL(op)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid op", K(ret));
|
||||
} else if (op->is_index_scan() && !(op->get_index_back())) {
|
||||
} else if (!op->need_replace_gen_column()) {
|
||||
//no need replace in index table non-return table scenario.
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < op->get_access_exprs().count(); ++i) {
|
||||
|
@ -580,7 +580,7 @@ int ObLogTableScan::generate_access_exprs()
|
||||
int ObLogTableScan::replace_gen_col_op_exprs(ObRawExprReplacer &replacer)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (is_index_scan() && !(get_index_back())) {
|
||||
if (!need_replace_gen_column()) {
|
||||
// do nothing.
|
||||
} else if (!replacer.empty()) {
|
||||
FOREACH_CNT_X(it, get_op_ordering(), OB_SUCC(ret)) {
|
||||
@ -4023,3 +4023,51 @@ int ObLogTableScan::prepare_rowkey_domain_id_dep_exprs()
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogTableScan::copy_gen_col_range_exprs()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSEArray<ObRawExpr*, 4> columns;
|
||||
bool need_copy = false;
|
||||
if (OB_ISNULL(get_plan())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (!need_replace_gen_column()) {
|
||||
//no need replace in index table non-return table scenario.
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < range_conds_.count(); ++i) {
|
||||
columns.reuse();
|
||||
if (OB_ISNULL(range_conds_.at(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (OB_FAIL(ObRawExprUtils::extract_column_exprs(range_conds_.at(i),
|
||||
columns, true))) {
|
||||
LOG_WARN("failed to extract column exprs", K(ret));
|
||||
} else {
|
||||
need_copy = false;
|
||||
for (int64_t j = 0; OB_SUCC(ret) && !need_copy && j < columns.count(); ++j) {
|
||||
ObRawExpr *expr = columns.at(j);
|
||||
if (OB_ISNULL(expr) ||
|
||||
OB_UNLIKELY(!expr->is_column_ref_expr())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (!static_cast<ObColumnRefRawExpr*>(expr)->is_generalized_column()) {
|
||||
// do nothing
|
||||
} else {
|
||||
need_copy = true;
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && need_copy) {
|
||||
ObRawExprCopier copier(get_plan()->get_optimizer_context().get_expr_factory());
|
||||
ObRawExpr *old_expr = range_conds_.at(i);
|
||||
if (OB_FAIL(copier.add_skipped_expr(columns))) {
|
||||
LOG_WARN("failed to add skipper expr", K(ret));
|
||||
} else if (OB_FAIL(copier.copy(old_expr, range_conds_.at(i)))) {
|
||||
LOG_WARN("failed to copy expr node", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -702,6 +702,8 @@ public:
|
||||
int get_index_name_list(ObIArray<ObString> &index_name_list) const;
|
||||
bool use_index_merge_by_hint() const;
|
||||
|
||||
int copy_gen_col_range_exprs();
|
||||
inline bool need_replace_gen_column() { return !(is_index_scan() && !(get_index_back())); }
|
||||
private: // member functions
|
||||
//called when index_back_ set
|
||||
int pick_out_query_range_exprs();
|
||||
|
Loading…
x
Reference in New Issue
Block a user