[MDEV-31009] JSON_SCHEMA_VALID does not properly validate the maximum/minimum value of a number Created: 2023-04-05  Updated: 2023-04-21  Resolved: 2023-04-13

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 11.1
Fix Version/s: 11.1.0

Type: Bug Priority: Critical
Reporter: Ramesh Sivaraman Assignee: Rucha Deodhar
Resolution: Won't Fix Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-27128 Implement JSON Schema Validation FUNC... Closed
Relates
relates to MDEV-31104 Implement strntold (string to long do... Open

 Description   

11.1.0-dbg>SET @schema='{"maximum": 18446744073709551}';
Query OK, 0 rows affected (0.000 sec)
 
11.1.0-dbg>

Actual result

11.1.0-dbg>SELECT JSON_SCHEMA_VALID(@schema,18446744073709552);
+----------------------------------------------+
| JSON_SCHEMA_VALID(@schema,18446744073709552) |
+----------------------------------------------+
|                                            1 |
+----------------------------------------------+
1 row in set (0.000 sec)
 
11.1.0-dbg>

Expected result

11.1.0-dbg>SELECT JSON_SCHEMA_VALID(@schema,18446744073709552);
+----------------------------------------------+
| JSON_SCHEMA_VALID(@schema,18446744073709552) |
+----------------------------------------------+
|                                            0 |
+----------------------------------------------+
1 row in set (0.000 sec)
 
11.1.0-dbg>

11.1.0-dbg>SET @schema='{"minimum": 18446744073709551}';
Query OK, 0 rows affected (0.000 sec)
 
11.1.0-dbg>

Actual result

11.1.0-dbg>SELECT JSON_SCHEMA_VALID(@schema,18446744073709550);
+----------------------------------------------+
| JSON_SCHEMA_VALID(@schema,18446744073709550) |
+----------------------------------------------+
|                                            1 |
+----------------------------------------------+
1 row in set (0.000 sec)
 
11.1.0-dbg>

Expected result

11.1.0-dbg>SELECT JSON_SCHEMA_VALID(@schema,18446744073709550);
+----------------------------------------------+
| JSON_SCHEMA_VALID(@schema,18446744073709550) |
+----------------------------------------------+
|                                            0 |
+----------------------------------------------+
1 row in set (0.000 sec)
 
11.1.0-dbg>



 Comments   
Comment by Rucha Deodhar [ 2023-04-13 ]

Wont fix for now. The json values are store in "double" type but the maximum values mentioned in the test case are bigger than what double can store. long double can store it, but currently we don't support long double. It needs to be implemented as a separate task.

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