• Vicențiu Ciorbaru's avatar
    MDEV-10122: MariaDB does not support group functions in some contexts where MySQL does · f675eab7
    Vicențiu Ciorbaru authored
    The problematic queries involve unions. For unions we have an
    optimization where we skip the ORDER BY clause in a query from one side
    of the union if it will be performed later due to UNION.
    EX:
    (SELECT a from t1 ORDER BY a) ORDER BY b;
    The first ordering by a is not necessary and it gets removed.
    
    The problem is that we still need to resolve the Items before removing the
    ORDER BY list from the
    SELECT_LEX structure. During this final resolve step however, we forgot to
    allow SET functions within the ORDER BY clause. This caused us to return
    an "Invalid use of group function" error during the checking performed
    by fix_fields in Item_sum::init_sum_func_check.
    f675eab7
sql_select.cc 851 KB