revision-id: 88b311e62ff0f977943984fd1bf6e33421267550 (mariadb-10.4.1-163-g88b311e62ff) parent(s): 3c305d3f1951f1667f84e48ddd98674c6318c39d author: Vicențiu Ciorbaru committer: Vicențiu Ciorbaru timestamp: 2019-02-14 23:03:53 +0200 message: Simplify column data adding method The add method does not need to provide the row order number. It was only used to detect if the minimum/maximum value was populated once or not, so as to force an update for the first encounter of a value. --- sql/sql_statistics.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index db214a1fe28..f903ce143a4 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -324,7 +324,7 @@ class Column_statistics_collected :public Column_statistics public: inline void init(THD *thd, Field * table_field); - inline bool add(ha_rows rowno); + inline bool add(); inline void finish(ha_rows rows); inline void cleanup(); }; @@ -2483,7 +2483,7 @@ void Column_statistics_collected::init(THD *thd, Field *table_field) */ inline -bool Column_statistics_collected::add(ha_rows rowno) +bool Column_statistics_collected::add() { bool err= 0; @@ -2492,9 +2492,11 @@ bool Column_statistics_collected::add(ha_rows rowno) else { column_total_length+= column->value_length(); - if (min_value && column->update_min(min_value, rowno == nulls)) + if (min_value && column->update_min(min_value, + is_null(COLUMN_STAT_MIN_VALUE))) set_not_null(COLUMN_STAT_MIN_VALUE); - if (max_value && column->update_max(max_value, rowno == nulls)) + if (max_value && column->update_max(max_value, + is_null(COLUMN_STAT_MAX_VALUE))) set_not_null(COLUMN_STAT_MAX_VALUE); if (count_distinct) err= count_distinct->add(); @@ -2761,7 +2763,7 @@ int collect_statistics_for_table(THD *thd, TABLE *table) table_field= *field_ptr; if (!bitmap_is_set(table->read_set, table_field->field_index)) continue; - if ((rc= table_field->collected_stats->add(rows))) + if ((rc= table_field->collected_stats->add())) break; } if (rc)