diff options
-rw-r--r-- | mysys/ptr_cmp.c | 15 | ||||
-rw-r--r-- | sql/filesort.cc | 3 |
2 files changed, 14 insertions, 4 deletions
diff --git a/mysys/ptr_cmp.c b/mysys/ptr_cmp.c index 6f9ab13c82b..cbd8ef49ef5 100644 --- a/mysys/ptr_cmp.c +++ b/mysys/ptr_cmp.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify 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) #else /* __sun */ +/** + Special case for ORDER BY / GROUP BY CHAR(0) NOT NULL + */ +static +int ptr_compare_zero_length(size_t *compare_length __attribute__((unused)), + uchar **a __attribute__((unused)), + uchar **b __attribute__((unused))) +{ + return 0; +} static int ptr_compare(size_t *compare_length, uchar **a, uchar **b); static int ptr_compare_0(size_t *compare_length, uchar **a, uchar **b); 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))) #else qsort2_cmp get_ptr_compare (size_t size) { + if (size == 0) + return (qsort2_cmp) ptr_compare_zero_length; if (size < 4) return (qsort2_cmp) ptr_compare; switch (size & 3) { @@ -85,6 +97,7 @@ static int ptr_compare(size_t *compare_length, uchar **a, uchar **b) reg3 int length= *compare_length; reg1 uchar *first,*last; + DBUG_ASSERT(length > 0); first= *a; last= *b; while (--length) { diff --git a/sql/filesort.cc b/sql/filesort.cc index 98900efb0d5..df48cdb273d 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -265,9 +265,6 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, } else { - /* filesort cannot handle zero-length records during merge. */ - DBUG_ASSERT(param.sort_length != 0); - if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer) { my_free(table_sort.buffpek); |