diff --git a/sql/item_sum.cc b/sql/item_sum.cc index a4d5cd82f..aea786f67 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3987,6 +3987,10 @@ int group_concat_key_cmp_with_order(const void *arg, const void *key1, Field *field = item->get_tmp_table_field(); if (!field) continue; + if (field->is_null_in_record((const uchar *)table->record[0])) { + return ((order_item)->direction == ORDER_ASC) ? 1 : -1; + } + uint offset = (field->offset(field->table->record[0]) - table->s->null_bytes); int res = field->cmp(pointer_cast(key1) + offset, @@ -3998,7 +4002,7 @@ int group_concat_key_cmp_with_order(const void *arg, const void *key1, item as double value. This would cause problems for case-changes and if the returned values are not the same we do the sort on. */ - return 1; + return ((order_item)->direction == ORDER_ASC) ? 1 : -1; } /**