mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed bug #25602. A query with DISTINCT in the select list to which
the loose scan optimization for grouping queries was applied returned a wrong result set when the query was used with the SQL_BIG_RESULT option. The SQL_BIG_RESULT option forces to use sorting algorithm for grouping queries instead of employing a suitable index. The current loose scan optimization is applied only for one table queries when the suitable index is covering. It does not make sense to use sort algorithm in this case. However the create_sort_index function does not take into account the possible choice of the loose scan to implement the DISTINCT operator which makes sorting unnecessary. Moreover the current implementation of the loose scan for queries with distinct assumes that sorting will never happen. Thus in this case create_sort_index should not call the function filesort.
This commit is contained in:
@ -12552,10 +12552,14 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
|
||||
|
||||
/*
|
||||
When there is SQL_BIG_RESULT do not sort using index for GROUP BY,
|
||||
and thus force sorting on disk.
|
||||
and thus force sorting on disk unless a group min-max optimization
|
||||
is going to be used as it is applied now only for one table queries
|
||||
with covering indexes.
|
||||
*/
|
||||
if ((order != join->group_list ||
|
||||
!(join->select_options & SELECT_BIG_RESULT)) &&
|
||||
!(join->select_options & SELECT_BIG_RESULT) ||
|
||||
select && select->quick &&
|
||||
select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) &&
|
||||
test_if_skip_sort_order(tab,order,select_limit,0))
|
||||
DBUG_RETURN(0);
|
||||
for (ORDER *ord= join->order; ord; ord= ord->next)
|
||||
|
Reference in New Issue
Block a user