summaryrefslogtreecommitdiff
path: root/sql/item_sum.h
diff options
context:
space:
mode:
authorVarun Gupta <varun.gupta@mariadb.com>2020-06-09 16:24:18 +0530
committerVarun Gupta <varun.gupta@mariadb.com>2020-06-12 23:47:38 +0530
commitab9bd6284c0cac74affed900bd45293fd652c5d6 (patch)
treec2c631495a0347b25d1a990da8226b8ed909a80f /sql/item_sum.h
parent0f6f0daa4da083197ff32b98d2f6f192110a173b (diff)
downloadmariadb-git-ab9bd6284c0cac74affed900bd45293fd652c5d6.tar.gz
MDEV-22840: JSON_ARRAYAGG gives wrong results with NULL values and ORDER by clause
The problem here is similar to the case with DISTINCT, the tree used for ORDER BY needs to also hold the null bytes of the record. This was not done for GROUP_CONCAT as NULLS are rejected by GROUP_CONCAT. Also introduced a comparator function for the order by tree to handle null values with JSON_ARRAYAGG.
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r--sql/item_sum.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h
index cbf74c48826..118b5b958f3 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -1853,6 +1853,8 @@ int group_concat_key_cmp_with_distinct_with_nulls(void* arg, const void* key1,
const void* key2);
int group_concat_key_cmp_with_order(void* arg, const void* key1,
const void* key2);
+int group_concat_key_cmp_with_order_with_nulls(void *arg, const void *key1,
+ const void *key2);
int dump_leaf_key(void* key_arg,
element_count count __attribute__((unused)),
void* item_arg);
@@ -1920,6 +1922,8 @@ protected:
const void* key2);
friend int group_concat_key_cmp_with_order(void* arg, const void* key1,
const void* key2);
+ friend int group_concat_key_cmp_with_order_with_nulls(void *arg,
+ const void *key1, const void *key2);
friend int dump_leaf_key(void* key_arg,
element_count count __attribute__((unused)),
void* item_arg);
@@ -2010,6 +2014,7 @@ public:
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_group_concat>(thd, this); }
qsort_cmp2 get_comparator_function_for_distinct();
+ qsort_cmp2 get_comparator_function_for_order_by();
uchar* get_record_pointer();
uint get_null_bytes();