1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-16230: Server crashes when Analyze format=json is run with a window function with empty PARTITION BY and ORDER BY clauses

Currently when both PARTITION BY and ORDER BY clauses are empty then we create a Item
with the first field in the select list and sort with that field.
It should be created as an Item_temptable_field instead of Item_field because the
print() function continues to work even if the table has been dropped.
This commit is contained in:
Varun Gupta
2020-06-02 16:31:53 +05:30
parent eba2d10ac5
commit f69278bcd0
3 changed files with 60 additions and 1 deletions

View File

@ -2872,7 +2872,8 @@ bool Window_funcs_sort::setup(THD *thd, SQL_SELECT *sel,
*/
ORDER *order= (ORDER *)alloc_root(thd->mem_root, sizeof(ORDER));
memset(order, 0, sizeof(*order));
Item *item= new (thd->mem_root) Item_field(thd, join_tab->table->field[0]);
Item *item= new (thd->mem_root) Item_temptable_field(thd,
join_tab->table->field[0]);
order->item= (Item **)alloc_root(thd->mem_root, 2 * sizeof(Item *));
order->item[1]= NULL;
order->item[0]= item;