1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-30703: JSON_SCHEMA_VALID : Enum array must have at least one value

Analysis: Current implementation does not check the number of elements in
the enum array and whether they are unique or not.
Fix: Add a counter that counts number of elements and before inserting the
element in the enum hash check whether it exists.
This commit is contained in:
Rucha Deodhar
2023-03-02 19:09:45 +05:30
parent d555f38af8
commit dffd1679ba
4 changed files with 67 additions and 20 deletions

View File

@@ -4590,4 +4590,19 @@ JSON_SCHEMA_VALID(@invalid_schema, '{"number1":3, "obj2":{"key1":3}}')
NULL
Warnings:
Warning 4038 Syntax error in JSON text in argument 1 to function 'json_schema_valid' at position 45
#
# MDEV-30703: JSON_SCHEMA_VALID : Enum array must have at least one value
#
SET @schema = '{
"type":"array",
"enum": []
}';
SELECT JSON_SCHEMA_VALID(@schema, '2');
ERROR HY000: Invalid value for keyword enum
SET @schema = '{
"type":"number",
"enum": [2, 2]
}';
SELECT JSON_SCHEMA_VALID(@schema, '2');
ERROR HY000: Invalid value for keyword enum
# End of 11.1 test