1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-30689: JSON_SCHEMA_VALID for type=array return 1 for any string that

starts with '['

Analysis:
When type is non-scalar and the json document has syntax error
then it is not detected during validating type. And Since other validate
functions take const argument, the error state is not stored eventually.
Fix:
After we run out of all schemas (in case of no error during validation) from
the schema list, go over the json document until there is error in parsing
or json doc has ended.
This commit is contained in:
Rucha Deodhar
2023-04-25 13:54:05 +05:30
parent 3ef111610b
commit 97675570ca
4 changed files with 69 additions and 1 deletions

View File

@ -3564,4 +3564,26 @@ SELECT JSON_SCHEMA_VALID(@property_names, '{"I_int1":3, "I_ob1":{"key1":"val1"}}
SET @@sql_mode= @old_sql_mode;
set global sql_mode=default;
--echo #
--echo # MDEV-30287: JSON_SCHEMA_VALID returns incorrect result for type=number
--echo #
SET @schema= '{"type":"number"}';
SELECT JSON_SCHEMA_VALID(@schema, '3.14');
SELECT JSON_SCHEMA_VALID(@schema, '0zzzz');
SELECT JSON_SCHEMA_VALID(@schema, '-#');
--echo #
--echo # MDEV-30689: JSON_SCHEMA_VALID for type=array return 1 for any string that starts with '['
--echo #
SET @schema_array= '{"type":"array"}';
SELECT JSON_SCHEMA_VALID(@schema_array, '[');
SELECT JSON_SCHEMA_VALID(repeat('[', 100000), json_object());
SELECT JSON_SCHEMA_VALID(json_object(), repeat('[', 10000000));
--echo # End of 11.1 test