diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2020-06-09 16:24:18 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2020-06-12 23:47:38 +0530 |
commit | ab9bd6284c0cac74affed900bd45293fd652c5d6 (patch) | |
tree | c2c631495a0347b25d1a990da8226b8ed909a80f /mysql-test/main/func_json.test | |
parent | 0f6f0daa4da083197ff32b98d2f6f192110a173b (diff) | |
download | mariadb-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 'mysql-test/main/func_json.test')
-rw-r--r-- | mysql-test/main/func_json.test | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index ed67df9aab8..7e4c94d8061 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -795,6 +795,24 @@ SELECT JSON_ARRAYAGG(DISTINCT a) FROM t1; DROP TABLE t1; --echo # +--echo # MDEV-22840: JSON_ARRAYAGG gives wrong results with NULL values and ORDER by clause +--echo # + +CREATE TABLE t1(a VARCHAR(255)); +INSERT INTO t1 VALUES ('red'),('blue'); + +SELECT JSON_ARRAYAGG(a) FROM t1; +SELECT JSON_ARRAYAGG(a ORDER BY a DESC) FROM t1; +SELECT JSON_ARRAYAGG(a ORDER BY a ASC) FROM t1; + +INSERT INTO t1 VALUES (NULL); + +SELECT JSON_ARRAYAGG(a) FROM t1; +SELECT JSON_ARRAYAGG(a ORDER BY a DESC) FROM t1; +SELECT JSON_ARRAYAGG(a ORDER BY a ASC) FROM t1; +DROP TABLE t1; + +--echo # --echo # End of 10.5 tests --echo # |