mirror of
https://github.com/MariaDB/server.git
synced 2026-05-06 15:15:34 +02:00
MDEV-9602 crash in st_key::actual_rec_per_key when group by constant
Problem was that cost_group_min_max() could not handle if group by was optimized away.
This commit is contained in:
parent
646c4cea58
commit
48f02af761
3 changed files with 35 additions and 1 deletions
|
|
@ -13105,7 +13105,17 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts,
|
|||
num_blocks= (ha_rows)(table_records / keys_per_block) + 1;
|
||||
|
||||
/* Compute the number of keys in a group. */
|
||||
keys_per_group= (ha_rows) index_info->actual_rec_per_key(group_key_parts - 1);
|
||||
if (!group_key_parts)
|
||||
{
|
||||
/* Summary over the whole table */
|
||||
keys_per_group= table_records;
|
||||
}
|
||||
else
|
||||
{
|
||||
keys_per_group= (ha_rows) index_info->actual_rec_per_key(group_key_parts -
|
||||
1);
|
||||
}
|
||||
|
||||
if (keys_per_group == 0) /* If there is no statistics try to guess */
|
||||
/* each group contains 10% of all records */
|
||||
keys_per_group= (table_records / 10) + 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue