@@ -2654,27 +2654,14 @@ int alloc_statistics_for_table(THD* thd, TABLE *table)
26542654 uint key_parts= table->s ->ext_key_parts ;
26552655 ulonglong *idx_avg_frequency= (ulonglong*) alloc_root (&table->mem_root ,
26562656 sizeof (ulonglong) * key_parts);
2657- /*
2658- uint hist_size= thd->variables.histogram_size;
2659- Histogram_type hist_type= (Histogram_type) (thd->variables.histogram_type);
2660- uchar *histogram= NULL;
2661- if (hist_size > 0)
2662- {
2663- if ((histogram= (uchar *) alloc_root(&table->mem_root,
2664- hist_size * columns)))
2665- bzero(histogram, hist_size * columns);
26662657
2667- }
2668- */
26692658 if (!table_stats || !column_stats || !index_stats || !idx_avg_frequency)
2670- // || (hist_size && !histogram))
26712659 DBUG_RETURN (1 );
26722660
26732661 table->collected_stats = table_stats;
26742662 table_stats->column_stats = column_stats;
26752663 table_stats->index_stats = index_stats;
26762664 table_stats->idx_avg_frequency = idx_avg_frequency;
2677- // table_stats->histograms= histogram;
26782665
26792666 memset (column_stats, 0 , sizeof (Column_statistics) * columns);
26802667
@@ -2977,7 +2964,7 @@ void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows, doubl
29772964 set_not_null (COLUMN_STAT_AVG_FREQUENCY);
29782965 }
29792966 else
2980- have_histogram= false ; // TODO: need this?
2967+ have_histogram= false ;
29812968
29822969 set_not_null (COLUMN_STAT_HIST_SIZE);
29832970 if (have_histogram && distincts)
@@ -3557,6 +3544,9 @@ void delete_stat_values_for_table_share(TABLE_SHARE *table_share)
35573544 delete column_stats->max_value ;
35583545 column_stats->max_value = NULL ;
35593546 }
3547+
3548+ delete column_stats->histogram_ ;
3549+ column_stats->histogram_ =NULL ;
35603550 }
35613551}
35623552
@@ -3599,7 +3589,7 @@ int read_histograms_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
35993589 TABLE_STATISTICS_CB *stats_cb= &table->s ->stats_cb ;
36003590 DBUG_ENTER (" read_histograms_for_table" );
36013591
3602- // histograms-todo: why do we use synchronization here, when we load
3592+ // histograms-todo: why do we use synchronization here, when we load
36033593 // histogram for the TABLE object, not TABLE_SHARE?
36043594 // is it because of the use of stats_cb->mem_root?
36053595 if (stats_cb->start_histograms_load ())
@@ -3613,21 +3603,16 @@ int read_histograms_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
36133603 DBUG_RETURN(1);
36143604 }
36153605 */
3616- // memset(histogram, 0, stats_cb->total_hist_size);
36173606
36183607 Column_stat column_stat (stat_tables[COLUMN_STAT].table , table);
36193608 for (Field **field_ptr= table->s ->field ; *field_ptr; field_ptr++)
36203609 {
36213610 Field *table_field= *field_ptr;
3622- // if (uint hist_size= table_field->read_stats->histogram.get_size())
36233611 if (table_field->read_stats ->histogram_type_on_disk != INVALID_HISTOGRAM)
36243612 {
36253613 column_stat.set_key_fields (table_field);
3626- // table_field->read_stats->histogram.set_values(histogram);
3627-
36283614 table_field->read_stats ->histogram_ =
36293615 column_stat.load_histogram (&stats_cb->mem_root );
3630- // histogram+= hist_size;
36313616 }
36323617 }
36333618 stats_cb->end_histograms_load ();
0 commit comments