mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +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:
@ -108,6 +108,13 @@ class Window_spec : public Sql_alloc
|
||||
|
||||
Window_spec *referenced_win_spec;
|
||||
|
||||
/*
|
||||
Window_spec objects are numbered by the number of their appearance in the
|
||||
query. This is used by compare_order_elements() to provide a predictable
|
||||
ordering of PARTITION/ORDER BY clauses.
|
||||
*/
|
||||
int win_spec_number;
|
||||
|
||||
Window_spec(LEX_STRING *win_ref,
|
||||
SQL_I_List<ORDER> *part_list,
|
||||
SQL_I_List<ORDER> *ord_list,
|
||||
|
Reference in New Issue
Block a user