[MDEV-25561] JSON_TABLE: bad error reporting for invalid json Created: 2021-04-28  Updated: 2022-06-01

Status: Open
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.6.0
Fix Version/s: 10.6

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


 Description   

Let's make an intentional mistake and feed JSON_TABLE an invalid JSON:

MariaDB [test]> set @json='
    '> [
    '>   {"name":"Laptop", "color":"black", price:null},
    '>   {"name":"Jeans",  "color":"blue", price:""}
    '> ]';
Query OK, 0 rows affected (0.000 sec)

Then let's try reading

MariaDB [test]> select * from json_table(@json, '$[*]' 
    ->   columns(
    ->    name  varchar(10) path '$.name', 
    ->    color varchar(10) path '$.color',
    ->    price varchar(10) path '$.price' error on empty ) 
    -> ) as jt;
ERROR 4176 (HY000): Field 'price' can't be set for JSON_TABLE 'jt'.

The error text doesn't indicate that the passed JSON was invalid.



 Comments   
Comment by Elena Stepanova [ 2021-04-28 ]

There is a lot of inconsistency in validating JSON document argument and the precedence of errors the validation reveals. I tried to summarize some in MDEV-25376, although the JSON doc chosen for the example there isn't optimal.

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