[MDEV-24616] JSON_EXTRACT produces incorrect result for double wildcard Created: 2021-01-18  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Major
Reporter: Sergei Petrunia Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Consider this example:

 
set @json=
'{
  "range_scan_alternatives":  {
    "ranges": [ "(1) <= (kp1) <= (1)",
                "(2) <= (kp1) <= (2)" ],
    "aaa":"bbb"
  }
}';
select json_valid(@json);
select json_extract(@json, '$**.range_scan_alternatives**.ranges');

On MariaDB, it produces:

MariaDB [test]> select json_extract(@json, '$**.range_scan_alternatives**.ranges');
+-------------------------------------------------------------+
| json_extract(@json, '$**.range_scan_alternatives**.ranges') |
+-------------------------------------------------------------+
| NULL                                                        |
+-------------------------------------------------------------+

I think the correct result should be what MySQL-8 produces:

mysql> select json_extract(@json, '$**.range_scan_alternatives**.ranges');
+-------------------------------------------------------------+
| json_extract(@json, '$**.range_scan_alternatives**.ranges') |
+-------------------------------------------------------------+
| [["(1) <= (kp1) <= (1)", "(2) <= (kp1) <= (2)"]]            |
+-------------------------------------------------------------+



 Comments   
Comment by Sergei Petrunia [ 2021-01-18 ]

Setting Affects-version to be all versions that have JSON_EXTRACT (no reason to believe otherwise). Please correct me if I am wrong.

Generated at Thu Feb 08 09:31:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.