[MDEV-30287] JSON_SCHEMA_VALID returns incorrect result for type=number Created: 2022-12-21  Updated: 2023-04-25  Resolved: 2023-04-25

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

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

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

 Description   

For the schema with type=number all objects starts with number or minus is validated as correct:
Test:

SET @schema= '{"type":"number"}';
 
SELECT JSON_SCHEMA_VALID(@schema, '3.14');
SELECT JSON_SCHEMA_VALID(@schema, '0zzzz');
SELECT JSON_SCHEMA_VALID(@schema, '-#');

Expected result:

JSON_SCHEMA_VALID(@schema, '3.14')
1
 
JSON_SCHEMA_VALID(@schema, '0zzzz')
0
 
SELECT JSON_SCHEMA_VALID(@schema, '-#')
0

It may be also necessary to generate a warning like here:

SELECT JSON_SCHEMA_VALID(@schema, '.0');
JSON_SCHEMA_VALID(@schema, '.0')
0
Warnings:
Warning	4038	Syntax error in JSON text in argument 3 to function 'json_schema_valid' at position 1

Actual result:

JSON_SCHEMA_VALID(@schema, '3.14')
1
 
JSON_SCHEMA_VALID(@schema, '0zzzz')
1
 
SELECT JSON_SCHEMA_VALID(@schema, '-#')
1



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

Patch on tree: https://github.com/MariaDB/server/tree/bb-MDEV-30287-json_schema

Comment by Alexey Botchkov [ 2023-04-22 ]

the fix for the MDEV-30689 seems to fix this too.
So comments basicaly same as there.

Comment by Rucha Deodhar [ 2023-04-25 ]

Can be fixed by MDEV-30689

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