[MDEV-30689] JSON_SCHEMA_VALID for type=array return 1 for any string that starts with '[' Created: 2023-02-20  Updated: 2023-11-27  Resolved: 2023-05-03

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: None
Fix Version/s: 11.1.1

Type: Bug Priority: Major
Reporter: Lena Startseva Assignee: Rucha Deodhar
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-27128 Implement JSON Schema Validation FUNC... Closed

 Description   

Case:

SET @schema_array= '{"type":"array"}';
SELECT JSON_SCHEMA_VALID(@schema_array, '[');

In case it is missed closing brace for array, but result is still 1:

JSON_SCHEMA_VALID(json_object(),'[[')
1

Expected result:

JSON_SCHEMA_VALID(json_object(),'[[')
0

Or maybe result+warning

The same problem presents for case:

SELECT JSON_SCHEMA_VALID(repeat('[', 100000), json_object());

Actual result:

SELECT JSON_SCHEMA_VALID(repeat('[', 100000), json_object());
JSON_SCHEMA_VALID(repeat('[', 100000), json_object())
1
Warnings:
Warning	4040	Limit of 32 on JSON nested structures depth is reached in argument 2 to function 'json_schema_valid' at position 32

Expected result (result must be NULL):

SELECT JSON_SCHEMA_VALID(repeat('[', 100000), json_object());
JSON_SCHEMA_VALID(repeat('[', 100000), json_object())
NULL
Warnings:
Warning	4040	Limit of 32 on JSON nested structures depth is reached in argument 2 to function 'json_schema_valid' at position 32

Also after fix bug the following case should also be tested:

SELECT JSON_SCHEMA_VALID(json_object(), repeat('[', 10000000));



 Comments   
Comment by Rucha Deodhar [ 2023-03-03 ]

patch:
https://github.com/MariaDB/server/tree/bb-MDEV-30689-json_schema

Comment by Lena Startseva [ 2023-03-03 ]

rucha174, I don't see in the patch test case for:

SELECT JSON_SCHEMA_VALID(json_object(), repeat('[', 10000000));

this case is different from:

SELECT JSON_SCHEMA_VALID(repeat('[', 100000), json_object());

Comment by Rucha Deodhar [ 2023-03-03 ]

lstartseva thanks for noticing ! Added.

Comment by Alexey Botchkov [ 2023-04-21 ]

see comments to the patch.

Comment by Alexey Botchkov [ 2023-04-26 ]

ok to push.

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