revision-id: 917afb5731adea15ecac9e29cdda75a72d7b5378 (mariadb-10.6.1-109-g917afb5731a) parent(s): 8ce59f8bb3ef0d7e5fbd441f9490eda2eeecc99e author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2021-08-31 14:17:33 +0300 message: Code cleanups part #3 --- sql/sql_statistics.cc | 12 +++++++----- sql/table.h | 13 +++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 9d561389360..976646fd78e 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -1967,7 +1967,7 @@ class Stat_table_write_iter class Histogram_builder { -public: +protected: Field *column; /* table field for which the histogram is built */ uint col_length; /* size of this field */ ha_rows records; /* number of records the histogram is built for */ @@ -1982,6 +1982,7 @@ class Histogram_builder /* number of distinct values that occured only once */ ulonglong count_distinct_single_occurence; +public: Histogram_builder(Field *col, uint col_len, ha_rows rows) : column(col), col_length(col_len), records(rows) { @@ -2934,7 +2935,8 @@ bool Column_statistics_collected::add() */ inline -void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows, double sample_fraction) +void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows, + double sample_fraction) { double val; @@ -3486,7 +3488,7 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables) if (table_field->read_stats->histogram_type_on_disk != INVALID_HISTOGRAM) have_histograms= true; } - table_share->stats_cb.total_hist_size= have_histograms? 1:0; // total_hist_size + table_share->stats_cb.have_histograms= have_histograms; /* Read statistics from the statistical table index_stats */ stat_table= stat_tables[INDEX_STAT].table; @@ -3626,7 +3628,7 @@ int read_histograms_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables) { TABLE_STATISTICS_CB *stats_cb= &table->s->stats_cb; DBUG_ENTER("read_histograms_for_table"); - + if (stats_cb->start_histograms_load()) { Column_stat column_stat(stat_tables[COLUMN_STAT].table, table); @@ -4547,7 +4549,7 @@ double Histogram_binary::range_selectivity(Field *field, } /* -Check whether the table is one of the persistent statistical tables. + Check whether the table is one of the persistent statistical tables. */ bool is_stat_table(const LEX_CSTRING *db, LEX_CSTRING *table) { diff --git a/sql/table.h b/sql/table.h index ba67275e093..221e18bc926 100644 --- a/sql/table.h +++ b/sql/table.h @@ -681,22 +681,19 @@ class TABLE_STATISTICS_CB Table_statistics *table_stats; /* Structure to access the statistical data */ /* - Total size of all histograms. A value of 0 means historams are not present, - and histograms_are_ready() can finish sooner. - - Currently we just set it to 1 when we expect to load histograms. - histogram-todo: rename this or even remove? + Whether the table has histograms. + (If the table has none, histograms_are_ready() can finish sooner) */ - ulong total_hist_size; + bool have_histograms; bool histograms_are_ready() const { - return !total_hist_size || hist_state.is_ready(); + return !have_histograms || hist_state.is_ready(); } bool start_histograms_load() { - return total_hist_size && hist_state.start_load(); + return have_histograms && hist_state.start_load(); } void end_histograms_load() { hist_state.end_load(); }