summaryrefslogtreecommitdiff
path: root/mysys/ptr_cmp.c
diff options
context:
space:
mode:
authorVarun Gupta <varunraiko1803@gmail.com>2018-10-14 10:30:23 -0700
committerVarun Gupta <varunraiko1803@gmail.com>2018-10-15 09:26:32 -0700
commit3c5f6aa21c54e2f93c96162a23f2e32772cf50bf (patch)
tree3aa3e933cc5d7c3bb7658e4060ddc2201f8ef772 /mysys/ptr_cmp.c
parent34f8a4071e2a77e3263f0fbf2adf1c9e3f8464b1 (diff)
downloadmariadb-git-3c5f6aa21c54e2f93c96162a23f2e32772cf50bf.tar.gz
MDEV-17020: Assertion `length > 0' failed in ptr_compare upon ORDER BY with bad conversion
This assert is hit when we do filesort using the priority queue and try to insert elements in the queue. The compare function used for the priority queue should handle the case for zerolength sortkey.
Diffstat (limited to 'mysys/ptr_cmp.c')
-rw-r--r--mysys/ptr_cmp.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/mysys/ptr_cmp.c b/mysys/ptr_cmp.c
index 6e373e98972..c9306dff14f 100644
--- a/mysys/ptr_cmp.c
+++ b/mysys/ptr_cmp.c
@@ -52,6 +52,11 @@ 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);
static int ptr_compare_2(size_t *compare_length, uchar **a, uchar **b);
static int ptr_compare_3(size_t *compare_length, uchar **a, uchar **b);
+static int degenerate_compare_func(size_t *compare_length, uchar **a, uchar **b)
+{
+ DBUG_ASSERT(*compare_length == 0);
+ return 0;
+}
#endif /* __sun */
/* Get a pointer to a optimal byte-compare function for a given size */
@@ -64,6 +69,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) degenerate_compare_func;
if (size < 4)
return (qsort2_cmp) ptr_compare;
switch (size & 3) {