Skip to content

Commit c18d4ac

Browse files
author
Tor Didriksen
committed
merge 5.5 => 5.6
2 parents f4b1963 + df9da6f commit c18d4ac

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

sql/filesort.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,18 @@ ha_rows filesort(THD *thd, TABLE *table, Filesort *filesort,
286286
{
287287
DBUG_PRINT("info", ("filesort PQ is not applicable"));
288288

289+
/*
290+
We need space for at least one record from each merge chunk, i.e.
291+
param->max_keys_per_buffer >= MERGEBUFF2
292+
See merge_buffers()),
293+
memory_available must be large enough for
294+
param->max_keys_per_buffer * (record + record pointer) bytes
295+
(the main sort buffer, see alloc_sort_buffer()).
296+
Hence this minimum:
297+
*/
289298
const ulong min_sort_memory=
290-
max(MIN_SORT_MEMORY, param.sort_length * MERGEBUFF2);
299+
max<ulong>(MIN_SORT_MEMORY,
300+
ALIGN_SIZE(MERGEBUFF2 * (param.rec_length + sizeof(uchar*))));
291301
while (memory_available >= min_sort_memory)
292302
{
293303
ha_rows keys= memory_available / (param.rec_length + sizeof(char*));

sql/sql_const.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878

7979
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
8080

81-
#define DEFAULT_SORT_MEMORY (256U* 1024U)
82-
#define MIN_SORT_MEMORY (32U * 1024U)
81+
#define DEFAULT_SORT_MEMORY (256UL* 1024UL)
82+
#define MIN_SORT_MEMORY (32UL * 1024UL)
8383

8484
/* Some portable defines */
8585

0 commit comments

Comments
 (0)