diff options
author | Igor Babaev <igor@askmonty.org> | 2016-10-24 10:15:11 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2016-10-26 20:45:35 -0700 |
commit | 9d4a0dde0ae3e0d46b4c5c0967c25862d467e94e (patch) | |
tree | 51da4792c18533900c08cfb9b07d3bd12af97819 /sql/sql_statistics.cc | |
parent | 26b87c332ff78a7aca04930ad86fbf7acc793222 (diff) | |
download | mariadb-git-9d4a0dde0ae3e0d46b4c5c0967c25862d467e94e.tar.gz |
Fixed bug mdev-11096.
1. When min/max value is provided the null flag for it must be set to 0
in the bitmap Culumn_statistics::column_stat_nulls.
2. When the calculation of the selectivity of the range condition
over a column requires min and max values for the column then we
have to check that these values are provided.
Diffstat (limited to 'sql/sql_statistics.cc')
-rw-r--r-- | sql/sql_statistics.cc | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 47a5a40ebeb..70080a6b4f1 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -1003,11 +1003,13 @@ public: switch (i) { case COLUMN_STAT_MIN_VALUE: + table_field->read_stats->min_value->set_notnull(); stat_field->val_str(&val); table_field->read_stats->min_value->store(val.ptr(), val.length(), &my_charset_bin); break; case COLUMN_STAT_MAX_VALUE: + table_field->read_stats->max_value->set_notnull(); stat_field->val_str(&val); table_field->read_stats->max_value->store(val.ptr(), val.length(), &my_charset_bin); @@ -3659,17 +3661,8 @@ double get_column_range_cardinality(Field *field, { double avg_frequency= col_stats->get_avg_frequency(); res= avg_frequency; - /* - psergey-todo: what does check for min_value, max_value mean? - min/max_value are set to NULL in alloc_statistics_for_table() and - alloc_statistics_for_table_share(). Both functions will immediately - call create_min_max_statistical_fields_for_table and - create_min_max_statistical_fields_for_table_share() respectively, - which will set min/max_value to be valid pointers, unless OOM - occurs. - */ if (avg_frequency > 1.0 + 0.000001 && - col_stats->min_value && col_stats->max_value) + col_stats->min_max_values_are_provided()) { Histogram *hist= &col_stats->histogram; if (hist->is_available()) @@ -3692,7 +3685,7 @@ double get_column_range_cardinality(Field *field, } else { - if (col_stats->min_value && col_stats->max_value) + if (col_stats->min_max_values_are_provided()) { double sel, min_mp_pos, max_mp_pos; |