bug#13949735: crash regression from bug#13694811.
There can be cases when the optimizer calls ha_partition::records_in_range when there are no matching partitions. So the DBUG_ASSERT of !tot_used_partitions does assert. Fixed by returning 0 instead when no matching partitions are found. This will avoid the crash. records_in_range will then try to find the biggest used partition, which will not find any partition and records_in_range will then return 0, meaning non rows can be found. Patch contributed by Davi Arnaut at twitter.
This commit is contained in:
parent
18fec1e9c1
commit
bed97f20ae
@ -6322,7 +6322,17 @@ ha_rows ha_partition::min_rows_for_estimate()
|
|||||||
DBUG_ENTER("ha_partition::min_rows_for_estimate");
|
DBUG_ENTER("ha_partition::min_rows_for_estimate");
|
||||||
|
|
||||||
tot_used_partitions= bitmap_bits_set(&m_part_info->used_partitions);
|
tot_used_partitions= bitmap_bits_set(&m_part_info->used_partitions);
|
||||||
DBUG_ASSERT(tot_used_partitions);
|
|
||||||
|
/*
|
||||||
|
All partitions might have been left as unused during partition pruning
|
||||||
|
due to, for example, an impossible WHERE condition. Nonetheless, the
|
||||||
|
optimizer might still attempt to perform (e.g. range) analysis where an
|
||||||
|
estimate of the the number of rows is calculated using records_in_range.
|
||||||
|
Hence, to handle this and other possible cases, use zero as the minimum
|
||||||
|
number of rows to base the estimate on if no partition is being used.
|
||||||
|
*/
|
||||||
|
if (!tot_used_partitions)
|
||||||
|
DBUG_RETURN(0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Allow O(log2(tot_partitions)) increase in number of used partitions.
|
Allow O(log2(tot_partitions)) increase in number of used partitions.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user