[FEAT MERGE]优化器技改patch到432
Co-authored-by: jingtaoye35 <1255153887@qq.com> Co-authored-by: qingzhu521 <q15000557748@gmail.com> Co-authored-by: akaError <lzg020616@163.com>
This commit is contained in:
@ -212,16 +212,24 @@ int ObLogExprValues::est_cost()
|
||||
int ObLogExprValues::do_re_est_cost(EstimateCostInfo ¶m, double &card, double &op_cost, double &cost)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(get_plan()) ||
|
||||
OB_ISNULL(get_stmt())) {
|
||||
if (OB_ISNULL(get_plan()) || OB_ISNULL(get_stmt())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (get_stmt()->is_insert_stmt() || is_values_table_) {
|
||||
} else if (get_stmt()->is_insert_stmt()) {
|
||||
ObOptimizerContext &opt_ctx = get_plan()->get_optimizer_context();
|
||||
card = get_stmt()->is_insert_stmt() ? static_cast<const ObInsertStmt*>(get_stmt())->get_insert_row_count() :
|
||||
get_values_row_count();
|
||||
card = static_cast<const ObInsertStmt*>(get_stmt())->get_insert_row_count();
|
||||
op_cost = ObOptEstCost::cost_get_rows(get_card(), opt_ctx);
|
||||
cost = op_cost;
|
||||
} else if (is_values_table_) {
|
||||
if (OB_ISNULL(table_def_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else {
|
||||
ObOptimizerContext &opt_ctx = get_plan()->get_optimizer_context();
|
||||
card = get_card();
|
||||
op_cost = ObOptEstCost::cost_filter_rows(table_def_->row_cnt_, filter_exprs_, opt_ctx);
|
||||
cost = op_cost;
|
||||
}
|
||||
} else {
|
||||
ObOptimizerContext &opt_ctx = get_plan()->get_optimizer_context();
|
||||
card = 1.0;
|
||||
@ -249,9 +257,18 @@ int ObLogExprValues::compute_one_row_info()
|
||||
if (OB_ISNULL(get_stmt())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (!get_stmt()->is_insert_stmt()) {
|
||||
is_at_most_one_row_ = get_values_row_count() <= 1;
|
||||
} else { /*do nothing*/ }
|
||||
} else if (get_stmt()->is_insert_stmt()) {
|
||||
/* do nothing */
|
||||
} else if (is_values_table_) {
|
||||
if (OB_ISNULL(table_def_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else {
|
||||
is_at_most_one_row_ = table_def_->row_cnt_ <= 1;
|
||||
}
|
||||
} else {
|
||||
is_at_most_one_row_ = true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -320,10 +337,26 @@ int ObLogExprValues::allocate_expr_post(ObAllocExprContext &ctx)
|
||||
LOG_WARN("failed to construct sequence values", K(ret));
|
||||
} else if (OB_FAIL(mark_probably_local_exprs())) {
|
||||
LOG_WARN("failed to mark local exprs", K(ret));
|
||||
} else if (is_values_table_) { /* defence code */
|
||||
if (OB_UNLIKELY(value_desc_.count() != get_output_exprs().count())) {
|
||||
} else if (is_values_table_) {
|
||||
// defence code for 4_2_1 values table
|
||||
if (OB_UNLIKELY(output_exprs_.count() != value_desc_.count())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("defence code, EXPRESSION request output_exprs equals to value_desc", K(ret));
|
||||
LOG_WARN("values table should output is same as value_desc", K(ret), K(output_exprs_), K(value_desc_));
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < output_exprs_.count(); i++) {
|
||||
ObSEArray<ObRawExpr *, 2> column_exprs;
|
||||
if (OB_FAIL(ObRawExprUtils::extract_column_exprs(output_exprs_.at(i), column_exprs))) {
|
||||
LOG_WARN("failed to extract column expr", K(ret));
|
||||
} else if (OB_UNLIKELY(column_exprs.count() >= 2)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("values table should output is same as value_desc", K(ret));
|
||||
} else if (column_exprs.empty()) {
|
||||
/* do nothing */
|
||||
} else if (OB_UNLIKELY(value_desc_.at(i) != column_exprs.at(0))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("values table should output is same as value_desc", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user