mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-26345 SELECT MIN on Spider table returns more rows than expected
The Spider storage engine ignored the implicit grouping when aggregation was converted to constant by the query optimizer. As a result, the Spider SE returned rows more than expected. To fix the problem, we notify the Spider SE of the existence of the implicit grouping via Query::distinct.
This commit is contained in:
@ -3278,13 +3278,12 @@ bool JOIN::make_aggr_tables_info()
|
||||
/*
|
||||
Check if the storage engine can intercept the query.
|
||||
|
||||
JOIN::optimize_stage2() might convert DISTINCT into GROUP BY and then
|
||||
optimize away GROUP BY (group_list). In such a case, we need to notify
|
||||
a storage engine supporting a group by handler of the existence of the
|
||||
original DISTINCT. Thus, we set select_distinct || group_optimized_away
|
||||
to Query::distinct.
|
||||
The query optimizer might optimize away aggregation functins or DISTINCT.
|
||||
In such a cage, we need to notify a storage engine supporting a group by
|
||||
handler of the existence of the original explicit or implicit grouping.
|
||||
Thus, we set select_distinct || implicit_grouping to Query::distinct.
|
||||
*/
|
||||
Query query= {&all_fields, select_distinct || group_optimized_away, tables_list,
|
||||
Query query= {&all_fields, select_distinct || implicit_grouping, tables_list,
|
||||
conds, group_list, order ? order : group_list, having};
|
||||
group_by_handler *gbh= ht->create_group_by(thd, &query);
|
||||
|
||||
|
Reference in New Issue
Block a user