diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 37f73adccb3..52b3811e60d 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -2109,7 +2109,12 @@ int alloc_statistics_for_table(THD* thd, TABLE *table) Histogram_type hist_type= (Histogram_type) (thd->variables.histogram_type); uchar *histogram= NULL; if (hist_size > 0) - histogram= (uchar *) alloc_root(&table->mem_root, hist_size * columns); + { + if ((histogram= (uchar *) alloc_root(&table->mem_root, + hist_size * columns))) + bzero(histogram, hist_size * columns); + + } if (!table_stats || !column_stats || !index_stats || !idx_avg_frequency || (hist_size && !histogram))