mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-19398: Assertion `item1->type() == Item::FIELD_ITEM ...
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.
This commit is contained in:
@ -8624,6 +8624,7 @@ bool st_select_lex::add_window_def(THD *thd,
|
||||
fields_in_window_functions+= win_part_list_ptr->elements +
|
||||
win_order_list_ptr->elements;
|
||||
}
|
||||
win_def->win_spec_number= window_specs.elements;
|
||||
return (win_def == NULL || window_specs.push_back(win_def));
|
||||
}
|
||||
|
||||
@ -8651,6 +8652,7 @@ bool st_select_lex::add_window_spec(THD *thd,
|
||||
win_order_list_ptr->elements;
|
||||
}
|
||||
thd->lex->win_spec= win_spec;
|
||||
win_spec->win_spec_number= window_specs.elements;
|
||||
return (win_spec == NULL || window_specs.push_back(win_spec));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user