Skip to content

Commit 0dedf55

Browse files
author
Tor Didriksen
committed
Bug#19660891 HANDLE_FATAL_SIGNAL (SIG=11) IN QUEUE_INSERT
Backport from 5.6 to 5.5 This makes filesort robust to misc variants of order by / group by on columns/expressions with zero length.
1 parent bb7951a commit 0dedf55

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

mysys/ptr_cmp.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -41,6 +41,16 @@ static int native_compare(size_t *length, unsigned char **a, unsigned char **b)
4141

4242
#else /* __sun */
4343

44+
/**
45+
Special case for ORDER BY / GROUP BY CHAR(0) NOT NULL
46+
*/
47+
static
48+
int ptr_compare_zero_length(size_t *compare_length __attribute__((unused)),
49+
uchar **a __attribute__((unused)),
50+
uchar **b __attribute__((unused)))
51+
{
52+
return 0;
53+
}
4454
static int ptr_compare(size_t *compare_length, uchar **a, uchar **b);
4555
static int ptr_compare_0(size_t *compare_length, uchar **a, uchar **b);
4656
static int ptr_compare_1(size_t *compare_length, uchar **a, uchar **b);
@@ -58,6 +68,8 @@ qsort2_cmp get_ptr_compare (size_t size __attribute__((unused)))
5868
#else
5969
qsort2_cmp get_ptr_compare (size_t size)
6070
{
71+
if (size == 0)
72+
return (qsort2_cmp) ptr_compare_zero_length;
6173
if (size < 4)
6274
return (qsort2_cmp) ptr_compare;
6375
switch (size & 3) {
@@ -85,6 +97,7 @@ static int ptr_compare(size_t *compare_length, uchar **a, uchar **b)
8597
reg3 int length= *compare_length;
8698
reg1 uchar *first,*last;
8799

100+
DBUG_ASSERT(length > 0);
88101
first= *a; last= *b;
89102
while (--length)
90103
{

sql/filesort.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,6 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
265265
}
266266
else
267267
{
268-
/* filesort cannot handle zero-length records during merge. */
269-
DBUG_ASSERT(param.sort_length != 0);
270-
271268
if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
272269
{
273270
my_free(table_sort.buffpek);

0 commit comments

Comments
 (0)