From fb648764be9a649d8365da62fdcf6877ef206b40 Mon Sep 17 00:00:00 2001 From: Hope Lee Date: Tue, 4 Jun 2024 16:48:46 +0800 Subject: [PATCH] Bugfix Last_query_cost could be negative number due to unmatched cost values in JOIN --- sql/sql_optimizer.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sql/sql_optimizer.cc b/sql/sql_optimizer.cc index e00753aaba4..9cde051f8e4 100644 --- a/sql/sql_optimizer.cc +++ b/sql/sql_optimizer.cc @@ -11079,6 +11079,8 @@ bool JOIN::compare_costs_of_subquery_strategies(Subquery_strategy *method) { Opt_trace_object trace_subqmat( trace, "execution_plan_for_potential_materialization"); const double saved_best_read = best_read; + const double saved_sort_cost = sort_cost; + const double saved_window_cost = windowing_cost; const ha_rows saved_best_rowcount = best_rowcount; POSITION *const saved_best_pos = best_positions; @@ -11138,6 +11140,8 @@ bool JOIN::compare_costs_of_subquery_strategies(Subquery_strategy *method) { *method = Subquery_strategy::SUBQ_MATERIALIZATION; } else { best_read = saved_best_read; + sort_cost = saved_sort_cost; + windowing_cost = saved_window_cost; best_rowcount = saved_best_rowcount; best_positions = saved_best_pos; /* -- 2.19.1.6.gb485710b