Skip to content

Commit 899dfb0

Browse files
committed
Code cleanups part #3
1 parent 859c14f commit 899dfb0

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

sql/sql_statistics.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,7 @@ class Stat_table_write_iter
19671967

19681968
class Histogram_builder
19691969
{
1970-
public:
1970+
protected:
19711971
Field *column; /* table field for which the histogram is built */
19721972
uint col_length; /* size of this field */
19731973
ha_rows records; /* number of records the histogram is built for */
@@ -1982,6 +1982,7 @@ class Histogram_builder
19821982
/* number of distinct values that occured only once */
19831983
ulonglong count_distinct_single_occurence;
19841984

1985+
public:
19851986
Histogram_builder(Field *col, uint col_len, ha_rows rows)
19861987
: column(col), col_length(col_len), records(rows)
19871988
{
@@ -2934,7 +2935,8 @@ bool Column_statistics_collected::add()
29342935
*/
29352936

29362937
inline
2937-
void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows, double sample_fraction)
2938+
void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows,
2939+
double sample_fraction)
29382940
{
29392941
double val;
29402942

@@ -3486,7 +3488,7 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
34863488
if (table_field->read_stats->histogram_type_on_disk != INVALID_HISTOGRAM)
34873489
have_histograms= true;
34883490
}
3489-
table_share->stats_cb.total_hist_size= have_histograms? 1:0; // total_hist_size
3491+
table_share->stats_cb.have_histograms= have_histograms;
34903492

34913493
/* Read statistics from the statistical table index_stats */
34923494
stat_table= stat_tables[INDEX_STAT].table;
@@ -3626,7 +3628,7 @@ int read_histograms_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
36263628
{
36273629
TABLE_STATISTICS_CB *stats_cb= &table->s->stats_cb;
36283630
DBUG_ENTER("read_histograms_for_table");
3629-
3631+
36303632
if (stats_cb->start_histograms_load())
36313633
{
36323634
Column_stat column_stat(stat_tables[COLUMN_STAT].table, table);
@@ -4547,7 +4549,7 @@ double Histogram_binary::range_selectivity(Field *field,
45474549
}
45484550

45494551
/*
4550-
Check whether the table is one of the persistent statistical tables.
4552+
Check whether the table is one of the persistent statistical tables.
45514553
*/
45524554
bool is_stat_table(const LEX_CSTRING *db, LEX_CSTRING *table)
45534555
{

sql/table.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -681,22 +681,19 @@ class TABLE_STATISTICS_CB
681681
Table_statistics *table_stats; /* Structure to access the statistical data */
682682

683683
/*
684-
Total size of all histograms. A value of 0 means historams are not present,
685-
and histograms_are_ready() can finish sooner.
686-
687-
Currently we just set it to 1 when we expect to load histograms.
688-
histogram-todo: rename this or even remove?
684+
Whether the table has histograms.
685+
(If the table has none, histograms_are_ready() can finish sooner)
689686
*/
690-
ulong total_hist_size;
687+
bool have_histograms;
691688

692689
bool histograms_are_ready() const
693690
{
694-
return !total_hist_size || hist_state.is_ready();
691+
return !have_histograms || hist_state.is_ready();
695692
}
696693

697694
bool start_histograms_load()
698695
{
699-
return total_hist_size && hist_state.start_load();
696+
return have_histograms && hist_state.start_load();
700697
}
701698

702699
void end_histograms_load() { hist_state.end_load(); }

0 commit comments

Comments
 (0)