1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

MDEV-26801: Valgrind/MSAN errors in Column_statistics_collected::finish ...

The problem was introduced in fix for MDEV-26724. That patch has made it
possible for histogram collection to fail. In particular, it fails for
non-assigned characters.

When histogram construction fails, we also abort the computation of
COUNT(DISTINCT). When we try to use the value, we get valgrind failures.

Switched the code to abort the statistics collection in this case.
This commit is contained in:
Sergei Petrunia
2021-10-11 22:47:26 +03:00
parent 93d5980435
commit 27539cd2c8
3 changed files with 13 additions and 9 deletions

View File

@@ -314,7 +314,7 @@ public:
inline void init(THD *thd, Field * table_field);
inline bool add();
inline void finish(MEM_ROOT *mem_root, ha_rows rows, double sample_fraction);
inline bool finish(MEM_ROOT *mem_root, ha_rows rows, double sample_fraction);
inline void cleanup();
};
@@ -2468,7 +2468,7 @@ bool Column_statistics_collected::add()
*/
inline
void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows,
bool Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows,
double sample_fraction)
{
double val;
@@ -2507,6 +2507,10 @@ void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows,
{
delete histogram;
histogram= NULL;
delete count_distinct;
count_distinct= NULL;
return true; // Error
}
}
@@ -2559,7 +2563,8 @@ void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows,
val= 1.0;
set_avg_frequency(val);
set_not_null(COLUMN_STAT_AVG_FREQUENCY);
}
}
return false;
}
@@ -2810,7 +2815,10 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
continue;
bitmap_set_bit(table->write_set, table_field->field_index);
if (!rc)
table_field->collected_stats->finish(&table->mem_root, rows, sample_fraction);
{
rc= table_field->collected_stats->finish(&table->mem_root, rows,
sample_fraction);
}
else
table_field->collected_stats->cleanup();
}