1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-30304: Json Range only affects first row of the result set

Analysis:
Parsing json path happens only once. When paring, we set types of path
(types_used) to use later. If the path type has range or wild card, only
then multiple values get added to the result set.
However for each row in the table, types_used still gets
overwritten to default (no multiple values) and is also not set again
(because path is already parsed). Since multiple values depend on the
type of path, they dont get added to result set either.

Fix:
set default for types_used only if path is not parsed already.
This commit is contained in:
Rucha Deodhar
2022-12-29 21:53:12 +05:30
parent 5d5735c181
commit b915b96f72
3 changed files with 34 additions and 1 deletions

View File

@ -1706,6 +1706,21 @@ SET @json2 = '{"kk":{"k1":"v1","k2":"v2","k3":"v3"}}';
SELECT JSON_OVERLAPS(@json2, @json1);
SELECT JSON_OVERLAPS(@json1, @json2);
--echo #
--echo # MDEV-30304: Json Range only affects first row of the result set
--echo #
CREATE TABLE t1 ( j JSON );
INSERT INTO t1 (j) VALUES ('[{"key1": 1, "key2": 1}, {"key3": 1, "key4": 1}]');
INSERT INTO t1 (j) VALUES ('[{"key1": 2, "key2": 2}, {"key3": 2, "key4": 2}, {"key5": 2, "key6": 2}]');
INSERT INTO t1 (j) VALUES ('[{"key1": 3, "key2": 3}, {"key3": 3, "key4": 3}, {"key5": 3}]');
SELECT JSON_EXTRACT(j, '$[0 to 1]') FROM t1 ;
SELECT JSON_EXTRACT(j, '$[*]') FROM t1 ;
DROP TABLE t1;
--echo #
--echo # End of 10.9 Test
--echo #