From d1cd5d47803ee18913c01098d54627c9dbd2228d Mon Sep 17 00:00:00 2001 From: wangt1xiuyi <13547954130@163.com> Date: Thu, 26 Aug 2021 12:37:17 +0800 Subject: [PATCH] fix late materialization and topk hint bug --- src/sql/optimizer/ob_select_log_plan.cpp | 7 +++++-- src/sql/resolver/dml/ob_dml_stmt.cpp | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sql/optimizer/ob_select_log_plan.cpp b/src/sql/optimizer/ob_select_log_plan.cpp index b29b60bd1b..510f5ae920 100644 --- a/src/sql/optimizer/ob_select_log_plan.cpp +++ b/src/sql/optimizer/ob_select_log_plan.cpp @@ -2261,11 +2261,12 @@ int ObSelectLogPlan::candi_allocate_late_materialization() } else { bool use_late_mat = false; ObLogicalOperator* best_plan = NULL; - ObLogTableScan* index_scan = NULL; + ObLogTableScan* best_index_scan = NULL; TableItem* nl_table_item = NULL; ObLogTableScan* nl_table_get = NULL; for (int64_t i = 0; OB_SUCC(ret) && i < candidates_.candidate_plans_.count(); ++i) { bool need = false; + ObLogTableScan* index_scan = NULL; CandidatePlan& plain_plan = candidates_.candidate_plans_.at(i); if (OB_FAIL(if_plan_need_late_materialization(plain_plan.plan_tree_, index_scan, need))) { LOG_WARN("failed to check if need late materialization", K(ret)); @@ -2288,6 +2289,7 @@ int ObSelectLogPlan::candi_allocate_late_materialization() } else if (NULL == best_plan || plain_plan.plan_tree_->get_cost() < best_plan->get_cost()) { best_plan = plain_plan.plan_tree_; use_late_mat = need; + best_index_scan = index_scan; } else { /*do nothing*/ } } @@ -2300,7 +2302,8 @@ int ObSelectLogPlan::candi_allocate_late_materialization() if (OB_FAIL(candidates_.candidate_plans_.push_back(CandidatePlan(best_plan)))) { LOG_WARN("failed to push back candidate plan", K(ret)); } else if (use_late_mat && !get_optimizer_context().is_cost_evaluation() && - OB_FAIL(adjust_late_materialization_structure(best_plan, index_scan, nl_table_get, nl_table_item))) { + OB_FAIL(adjust_late_materialization_structure( + best_plan, best_index_scan, nl_table_get, nl_table_item))) { LOG_WARN("failed to adjust late materialization stmt", K(ret)); } else { candidates_.plain_plan_.first = best_plan->get_cost(); diff --git a/src/sql/resolver/dml/ob_dml_stmt.cpp b/src/sql/resolver/dml/ob_dml_stmt.cpp index f8c5d38c0a..2f0991cd8e 100644 --- a/src/sql/resolver/dml/ob_dml_stmt.cpp +++ b/src/sql/resolver/dml/ob_dml_stmt.cpp @@ -3702,7 +3702,6 @@ int ObDMLStmt::copy_query_hint(ObDMLStmt* from, ObDMLStmt* to) LOG_WARN("get null stmt", K(ret), K(from), K(to)); } else { to->get_stmt_hint().frozen_version_ = from->get_stmt_hint().frozen_version_; - to->get_stmt_hint().topk_precision_ = from->get_stmt_hint().topk_precision_; to->get_stmt_hint().use_jit_policy_ = from->get_stmt_hint().use_jit_policy_; to->get_stmt_hint().force_trace_log_ = from->get_stmt_hint().force_trace_log_; to->get_stmt_hint().read_consistency_ = from->get_stmt_hint().read_consistency_;