summaryrefslogtreecommitdiff
path: root/mysql-test/main/func_json.test
diff options
context:
space:
mode:
authorRucha Deodhar <rucha.deodhar@mariadb.com>2022-12-29 21:53:12 +0530
committerRucha Deodhar <rucha.deodhar@mariadb.com>2023-01-17 18:24:16 +0530
commitb915b96f7224e04d4509f1e4c6a4193347715097 (patch)
treea024eaf3232e9efadc8b28d82b728d0df3105d13 /mysql-test/main/func_json.test
parent5d5735c181f1300c7b208f865806268b16eec5c6 (diff)
downloadmariadb-git-b915b96f7224e04d4509f1e4c6a4193347715097.tar.gz
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.
Diffstat (limited to 'mysql-test/main/func_json.test')
-rw-r--r--mysql-test/main/func_json.test15
1 files changed, 15 insertions, 0 deletions
diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test
index da830ed08fd..e0614a252ce 100644
--- a/mysql-test/main/func_json.test
+++ b/mysql-test/main/func_json.test
@@ -1707,6 +1707,21 @@ 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 #