mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-6442: Assertion `join->best_read < double(...)' failed with optimizer_use_condition_selectivity >=3
- Fix the crash by making get_column_range_cardinality() to handle the special case where Column_stats objects is an all-zeros object (the question of what is the point of having Field::read_stats point to such object remains a mystery) - Added a few comments. Learning the code still.
This commit is contained in:
@ -3502,7 +3502,7 @@ double get_column_range_cardinality(Field *field,
|
||||
!(range_flag & NEAR_MIN);
|
||||
|
||||
if (col_non_nulls < 1)
|
||||
res= 0;
|
||||
res= 0; /* this is likely wrong, see MDEV-6843 */
|
||||
else if (min_endp && max_endp && min_endp->length == max_endp->length &&
|
||||
!memcmp(min_endp->key, max_endp->key, min_endp->length))
|
||||
{
|
||||
@ -3515,6 +3515,15 @@ double get_column_range_cardinality(Field *field,
|
||||
{
|
||||
double avg_frequency= col_stats->get_avg_frequency();
|
||||
res= avg_frequency;
|
||||
/*
|
||||
psergey-todo: what does check for min_value, max_value mean?
|
||||
min/max_value are set to NULL in alloc_statistics_for_table() and
|
||||
alloc_statistics_for_table_share(). Both functions will immediately
|
||||
call create_min_max_statistical_fields_for_table and
|
||||
create_min_max_statistical_fields_for_table_share() respectively,
|
||||
which will set min/max_value to be valid pointers, unless OOM
|
||||
occurs.
|
||||
*/
|
||||
if (avg_frequency > 1.0 + 0.000001 &&
|
||||
col_stats->min_value && col_stats->max_value)
|
||||
{
|
||||
@ -3530,6 +3539,11 @@ double get_column_range_cardinality(Field *field,
|
||||
avg_frequency / col_non_nulls);
|
||||
}
|
||||
}
|
||||
else if (avg_frequency == 0.0)
|
||||
{
|
||||
/* This actually means there is no statistics data */
|
||||
res= tab_records;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user