MDEV-17796 WHERE filter is ignored by DISTINCT IFNULL(GROUP_CONCAT(X), Y)

with GROUP BY + ORDER BY

The method JOIN::create_postjoin_aggr_table() should not call
call JOIN::add_sorting_to_table() unless the first non-constant join
table is passed as the first parameter to the method.
This commit is contained in:
Igor Babaev 2019-04-23 23:10:46 -07:00
commit 5fc8dd8b82
3 changed files with 29 additions and 1 deletions

View file

@ -3007,7 +3007,8 @@ JOIN::create_postjoin_aggr_table(JOIN_TAB *tab, List<Item> *table_fields,
if (setup_sum_funcs(thd, sum_funcs))
goto err;
if (!group_list && !table->distinct && order && simple_order)
if (!group_list && !table->distinct && order && simple_order &&
tab == join_tab + const_tables)
{
DBUG_PRINT("info",("Sorting for order"));
THD_STAGE_INFO(thd, stage_sorting_for_order);