diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2020-06-02 16:31:53 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2020-06-04 17:03:03 +0530 |
commit | f69278bcd0a1ffba767918b040f6e8465c37397b (patch) | |
tree | 9486596502cf0ef3c773983a9d0461a856a79da1 /sql/sql_window.cc | |
parent | eba2d10ac53d1d2f975027ba2b2ca39d9c9b98ad (diff) | |
download | mariadb-git-f69278bcd0a1ffba767918b040f6e8465c37397b.tar.gz |
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.
Diffstat (limited to 'sql/sql_window.cc')
-rw-r--r-- | sql/sql_window.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/sql_window.cc b/sql/sql_window.cc index b258b8f56c9..18075d179d5 100644 --- a/sql/sql_window.cc +++ b/sql/sql_window.cc @@ -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; |