diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2021-01-12 11:17:37 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2021-01-12 18:47:35 +0530 |
commit | 3b94309a6cec8d8149c9f312229d18227036e01d (patch) | |
tree | cea3bdd80c6102be59f643657c1b40b444e16cf4 /sql/sql_statistics.cc | |
parent | a216672dab202207a21f9d2ffdc4b00eb958060f (diff) | |
download | mariadb-git-3b94309a6cec8d8149c9f312229d18227036e01d.tar.gz |
MDEV-23753: SIGSEGV in Column_stat::store_stat_fields
For EITS collection min and max fields are allocated for each column
that is set in the read_set bitmap of a table. This allocation of min and max
fields happens inside alloc_statistics_for_table.
For a partitioned table ha_rnd_init is called inside the function
collect_statistics_for_table which sets the read_set bitmap for the columns
inside the partition expression. This happens only when there is a write lock
on the partitioned table.
But the allocation happens before this, so min and max fields are not allocated
for the columns involved in the partition expression.
This resulted in a crash, as the EITS statistics were collected but there was
no min and max field to store the value to.
The fix would be to call ha_rnd_init inside the function alloc_statistics_for_table
that would make sure that min and max fields are allocated for the columns
involved in the partition expression.
Diffstat (limited to 'sql/sql_statistics.cc')
-rw-r--r-- | sql/sql_statistics.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index ab8edbf584b..b63172045e6 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -2110,6 +2110,10 @@ int alloc_statistics_for_table(THD* thd, TABLE *table) ulonglong *idx_avg_frequency= (ulonglong*) alloc_root(&table->mem_root, sizeof(ulonglong) * key_parts); + if (table->file->ha_rnd_init(TRUE)) + DBUG_RETURN(1); + table->file->ha_rnd_end(); + uint columns= 0; for (field_ptr= table->field; *field_ptr; field_ptr++) { |