From adbad5e36f99f64eedbcc43f98215f5e52f10cad Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Tue, 25 Apr 2023 14:34:31 +0700 Subject: MDEV-31113 Server crashes in store_length / Type_handler_string_result::make_sort_key with DISTINCT and group function Fix-up for commit 476b24d084e7e717310155bb986eb086d3c1e1a6 Author: Monty Date: Thu Feb 16 14:19:33 2023 +0200 MDEV-20057 Distinct SUM on CROSS JOIN and grouped returns wrong result which misses initializing of sorder->suffix_length. In this commit the initialization is implemented by passing MY_ZEROFILL flag to the allocation of SORT_FIELD elements --- sql/sql_select.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sql/sql_select.cc') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 03a2c3d0853..56a185acdd5 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -24226,7 +24226,7 @@ JOIN_TAB::remove_duplicates() if (!(sortorder= (SORT_FIELD*) my_malloc((fields->elements+1) * sizeof(SORT_FIELD), - MYF(MY_WME)))) + MYF(MY_WME | MY_ZEROFILL)))) DBUG_RETURN(TRUE); /* Calculate how many saved fields there is in list */ @@ -24245,7 +24245,6 @@ JOIN_TAB::remove_duplicates() else { /* Item is not stored in temporary table, remember it */ - sorder->field= 0; // Safety, not used sorder->item= item; /* Calculate sorder->length */ item->type_handler()->sortlength(thd, item, sorder); -- cgit v1.2.1