• Igor Babaev's avatar
    MDEV-28616 Crash when using derived table over union with order by clause · 4652260d
    Igor Babaev authored
    This bug manifested itself when the server processed a query containing
    a derived table over union whose ORDER BY clause included a subquery
    with unresolvable column reference. For such a query the server crashed
    when trying to resolve column references in the ORDER BY clause used by
    union.
    For any union with ORDER BY clause an extra SELECT_LEX structure is created
    and it is attached to SELECT_LEX_UNIT structure of the union via the field
    fake_select_lex. The outer context for fake_select_lex must be the same as
    for other selects of the union. If the union is used in the FROM list of
    a derived table then the outer context for fake_select_lex must be set to
    NULL in line with other selects of the union. It was not done and it
    caused a crash when searching for possible resolution of an unresolvable
    column reference occurred in a subquery used in the ORDER BY clause.
    
    Approved by Oleksandr Byelkin <sanja@mariadb.com>
    4652260d
derived.test 46.1 KB