diff options
author | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2023-04-25 13:54:05 +0530 |
---|---|---|
committer | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2023-05-03 12:31:45 +0530 |
commit | 97675570ca1e5a3428be1bf6d125f401e37e539d (patch) | |
tree | 8080873e8b0a88d1023fbadc121cb7c2a45e2851 /mysql-test/main/func_json.test | |
parent | 3ef111610b7f8a6a323975cfdf4a4257feb9dcd9 (diff) | |
download | mariadb-git-97675570ca1e5a3428be1bf6d125f401e37e539d.tar.gz |
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.
Diffstat (limited to 'mysql-test/main/func_json.test')
-rw-r--r-- | mysql-test/main/func_json.test | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index d0588655dff..e0da9819785 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -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 |