• Sergei Petrunia's avatar
    MDEV-19398: Assertion `item1->type() == Item::FIELD_ITEM ... · ba4927e5
    Sergei Petrunia authored
    Window Functions code tries to minimize the number of times it
    needs to sort the select's resultset by finding "compatible"
    OVER (PARTITION BY ... ORDER BY ...) clauses.
    
    This employs compare_order_elements(). That function assumed that
    the order expressions are Item_field-derived objects (that refer
    to a temp.table). But this is not always the case: one can
    construct queries order expressions are arbitrary item expressions.
    
    Add handling for such expressions: sort them according to the window
    specification they appeared in.
    This means we cannot detect that two compatible PARTITION BY clauses
    that use expressions can share the sorting step.
    But at least we won't crash.
    ba4927e5
sql_window.h 5.89 KB