Commit 367c780d authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru Committed by Sergei Petrunia

Fix bug in WITH ties

The old code had a bug when the normal sorting code where
where eliminated as part of "Using index for group-by" optimization.
The effect was that the result contained more rows than expected
parent aa5e7880
...@@ -4085,7 +4085,14 @@ bool JOIN::make_aggr_tables_info() ...@@ -4085,7 +4085,14 @@ bool JOIN::make_aggr_tables_info()
*/ */
if (unit->lim.is_with_ties()) if (unit->lim.is_with_ties())
{ {
if (alloc_order_fields(this, order, with_ties_order_count)) /*
When ORDER BY is eliminated, we make use of the GROUP BY list.
We've already counted how many elements from ORDER BY
must be evaluated as part of WITH TIES so we use that.
*/
ORDER *order_src = order ? order : group_list;
if (alloc_order_fields(this, order_src,
with_ties_order_count))
DBUG_RETURN(true); DBUG_RETURN(true);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment