From a48e63c5fe444c251cbb476488ddd448107a3326 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Fri, 27 Aug 2021 16:49:45 +0300 Subject: [PATCH] Fix compile error and test failure: - Don't use 'res' uninitialized - multiply it by col_non_nulls before set_if_bigger(...) call. --- sql/sql_statistics.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index a518aa44958..43cf4d7dbdd 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -4369,8 +4369,8 @@ double get_column_range_cardinality(Field *field, if (hist && hist->is_usable(thd)) { sel= hist->range_selectivity(field, min_endp, max_endp); - set_if_bigger(res, col_stats->get_avg_frequency()); - } else + } + else { double min_mp_pos, max_mp_pos; if (min_endp && !(field->null_ptr && min_endp->key[0])) @@ -4395,6 +4395,7 @@ double get_column_range_cardinality(Field *field, sel = (max_mp_pos - min_mp_pos); } res= col_non_nulls * sel; + set_if_bigger(res, col_stats->get_avg_frequency()); } else res= col_non_nulls;