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

MDEV-31411: JSON_ARRAY_INTERSECT/JSON_OBJECT_FILTER_KEYS should fetch

data from a table similar to other JSON functions

Analysis:
Since we are fetching values for every row ( because we are running SELECT
for all rows of a table ), correct value can be only obtained at the time of
calling val_int() because it is called to get value for each row.
Fix:
Set up hash for each row instead of doing it during fixing fields.
This commit is contained in:
Rucha Deodhar
2023-07-04 14:39:57 +05:30
parent d0f8dfbcf0
commit 5c5123dfe0
5 changed files with 93 additions and 23 deletions

View File

@ -1,3 +1,5 @@
--source include/have_innodb.inc
select json_valid('[1, 2]');
select json_valid('"string"}');
select json_valid('{"key1":1, "key2":[2,3]}');
@ -3947,6 +3949,24 @@ SELECT JSON_OBJECT_TO_ARRAY(@obj1);
SET @arr1= '[1, 2, 3]';
SELECT JSON_OBJECT_TO_ARRAY(@arr1);
--echo #
--echo # MDEV-31411: JSON_ARRAY_INTERSECT/JSON_OBJECT_FILTER_KEYS should fetch
--echo # data from a table similar to other JSON functions
--echo #
CREATE TABLE t1 (
c1 longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(c1)),
c2 longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`c2`))
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
INSERT INTO t1 VALUES('[1,2,3]', '[2, 3, 4]'), ('[2 ,3, 4]', '[4, 5, 6]');
SELECT JSON_ARRAY_INTERSECT(c1, c2) FROM t1;
DROP TABLE t1;
--echo #
--echo # End of 11.2 Test
--echo #