diff options
author | Sergei Golubchik <serg@mariadb.org> | 2021-02-01 13:01:12 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-02-22 19:27:12 +0100 |
commit | 06a791aa129d80762d6e999a8d05940b52eda16c (patch) | |
tree | f1ec625294e4461195d67c8e1cd107521637da21 /sql/sql_statistics.cc | |
parent | caad32ca927fa583b292a9d1d77f091affecfc5a (diff) | |
download | mariadb-git-06a791aa129d80762d6e999a8d05940b52eda16c.tar.gz |
MDEV-23753: SIGSEGV in Column_stat::store_stat_fields
only collect persistent stats for columns explicitly listed
by the user in the ANALYZE TABLE PERSISTENT FOR COLUMNS (...)
clause. The engine can extend table->read_set as much as
it wants, it should not affect the collected statistics.
Test case from the 3b94309a6c applies - it used to crash,
because ha_partition extended table->read_set after the loop that
initialized some objects based on bits in the read_set but before the
loop that used these objects based on bits in the read_set.
Diffstat (limited to 'sql/sql_statistics.cc')
-rw-r--r-- | sql/sql_statistics.cc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index b7116f701ae..b9d70a1db67 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -2155,15 +2155,13 @@ int alloc_statistics_for_table(THD* thd, TABLE *table) for (field_ptr= table->field; *field_ptr; field_ptr++, column_stats++) { - (*field_ptr)->collected_stats= column_stats; - (*field_ptr)->collected_stats->max_value= NULL; - (*field_ptr)->collected_stats->min_value= NULL; if (bitmap_is_set(table->read_set, (*field_ptr)->field_index)) { column_stats->histogram.set_size(hist_size); column_stats->histogram.set_type(hist_type); column_stats->histogram.set_values(histogram); histogram+= hist_size; + (*field_ptr)->collected_stats= column_stats; } } @@ -2612,7 +2610,7 @@ int collect_statistics_for_table(THD *thd, TABLE *table) for (field_ptr= table->field; *field_ptr; field_ptr++) { table_field= *field_ptr; - if (!bitmap_is_set(table->read_set, table_field->field_index)) + if (!table_field->collected_stats) continue; table_field->collected_stats->init(thd, table_field); } @@ -2639,7 +2637,7 @@ int collect_statistics_for_table(THD *thd, TABLE *table) for (field_ptr= table->field; *field_ptr; field_ptr++) { table_field= *field_ptr; - if (!bitmap_is_set(table->read_set, table_field->field_index)) + if (!table_field->collected_stats) continue; if ((rc= table_field->collected_stats->add(rows))) break; @@ -2667,7 +2665,7 @@ int collect_statistics_for_table(THD *thd, TABLE *table) for (field_ptr= table->field; *field_ptr; field_ptr++) { table_field= *field_ptr; - if (!bitmap_is_set(table->read_set, table_field->field_index)) + if (!table_field->collected_stats) continue; bitmap_set_bit(table->write_set, table_field->field_index); if (!rc) @@ -2771,7 +2769,7 @@ int update_statistics_for_table(THD *thd, TABLE *table) for (Field **field_ptr= table->field; *field_ptr; field_ptr++) { Field *table_field= *field_ptr; - if (!bitmap_is_set(table->read_set, table_field->field_index)) + if (!table_field->collected_stats) continue; restore_record(stat_table, s->default_values); column_stat.set_key_fields(table_field); |