mirror of
https://github.com/MariaDB/server.git
synced 2025-11-09 11:41:36 +03:00
MDEV-36809: json_array_intersect crashs when unused table ref provided
Analysis: So, there were two problems that needed to be fixed. 1) To fix the crash. 2) After fixing the crash, the result was wrong. Reason for crash: When we pass the hash to get_intersect_between_arrays(), We were initialially not passing it value, so the operations were not performed correctly. Reason for wrong result: The number of rows that it was returning were same as that in the table, but, only the first row had correct ouput, rest of them were NULL (it should also be the result of interection). This was because we modified the "items" HASH by deleting the "seen" elements. So for next rows, it did not have the elements it should have in the hash. Fix: 1) To fix the crash: pass the HASH by reference 2) To fix incorrect result: Maintain a separate "seen" hash, if an item is found the the "items" hash, delete it ony temporarily and put it in the seen hash. At then end, put the items from "seen" back into "items" and reset "seen".
This commit is contained in:
committed by
Daniel Black
parent
44dc149c78
commit
6c56c92a6c
@@ -4175,6 +4175,9 @@ SET CHARACTER SET utf8;
|
||||
SET @obj1='{ "a": 1,"b": 2,"c": 3}';
|
||||
SELECT JSON_OBJECT_FILTER_KEYS (@obj1,@arr1);
|
||||
|
||||
SET character_set_database=default;
|
||||
SET CHARACTER SET default;
|
||||
|
||||
--echo # End of 11.2 Test
|
||||
|
||||
--echo # Beginning of 11.4 Test
|
||||
@@ -4188,4 +4191,9 @@ SELECT JSON_OBJECT_FILTER_KEYS (@obj1,@arr1);
|
||||
|
||||
SELECT json_array_intersect(@a,@b);
|
||||
|
||||
--echo # MDEV-36809: json_array_intersect crashs when unused table ref provided
|
||||
--echo #
|
||||
select json_array_intersect('[["1", "7"], ["2", "6"], ["4", "5"], ["3", "8"]]', '[["2","6"],["3","8"],["4","5"],["1","7"]]') as result from mysql.user;
|
||||
SELECT ( WITH x AS ( WITH x ( x ) AS ( SELECT ( 1.000000 ) ) SELECT x FROM x ) SELECT * FROM x WHERE ( SELECT AVG ( x ) OVER ( ORDER BY JSON_ARRAY_INTERSECT ( '[["1", "7"], ["2", "6"], ["3", "8"]]' , '[["2","6"],["3","8"],["4","5"],["1","7"]]' ) ) FROM x ) );
|
||||
|
||||
--echo # End of 11.4 Test
|
||||
|
||||
Reference in New Issue
Block a user