mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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.
This commit is contained in:
@ -794,6 +794,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 #
|
||||
|
Reference in New Issue
Block a user