diff options
| author | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2023-03-02 17:19:36 +0530 |
|---|---|---|
| committer | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2023-04-26 11:00:09 +0530 |
| commit | 2c4c7c8b02140ff3abb8325f6261ccf1ae18b477 (patch) | |
| tree | eb823175f618dc8d059bc34eb05baba638170891 /mysql-test/main | |
| parent | dffd1679ba97e5e8145575f0f11cb87553670c6f (diff) | |
| download | mariadb-git-2c4c7c8b02140ff3abb8325f6261ccf1ae18b477.tar.gz | |
MDEV-30704: JSON_SCHEMA_VALID: multipleOf must be greater than zero
Analysis: multipleOf must be strictly greater then 0. However the
implementation only disallowed values strcitly less than 0
Fix: check if value is less than or equal to 0 instead of less than 0 and
return true.
Also fixed the incorrect return value for some other keywords.
Diffstat (limited to 'mysql-test/main')
| -rw-r--r-- | mysql-test/main/func_json.result | 29 | ||||
| -rw-r--r-- | mysql-test/main/func_json.test | 39 |
2 files changed, 68 insertions, 0 deletions
diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 5fee9ce4c32..11eb3a5aefb 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -4605,4 +4605,33 @@ SET @schema = '{ }'; SELECT JSON_SCHEMA_VALID(@schema, '2'); ERROR HY000: Invalid value for keyword enum +# +# MDEV-30704: JSON_SCHEMA_VALID: multipleOf must be greater than zero +# +SET @schema = '{ + "multipleOf": 0 + }'; +SELECT JSON_SCHEMA_VALID(@schema, '2'); +ERROR HY000: Invalid value for keyword multipleOf +SET @schema= '{ "maxLength" : -3}'; +SELECT JSON_SCHEMA_VALID(@schema, '2'); +ERROR HY000: Invalid value for keyword maxLength +SET @schema= '{ "minLength" : -3}'; +SELECT JSON_SCHEMA_VALID(@schema, '2'); +ERROR HY000: Invalid value for keyword minLength +SET @schema= '{ "maxProperties" : -3}'; +SELECT JSON_SCHEMA_VALID(@schema, '2'); +ERROR HY000: Invalid value for keyword maxProperties +SET @schema= '{ "minProperties" : -3}'; +SELECT JSON_SCHEMA_VALID(@schema, '2'); +ERROR HY000: Invalid value for keyword minProperties +SET @schema= '{ "maxItems" : -3}'; +SELECT JSON_SCHEMA_VALID(@schema, '2'); +ERROR HY000: Invalid value for keyword maxItems +SET @schema= '{ "minItems" : -3}'; +SELECT JSON_SCHEMA_VALID(@schema, '2'); +ERROR HY000: Invalid value for keyword maxLength +SET @schema= '{ "items" : ["str1"]}'; +SELECT JSON_SCHEMA_VALID(@schema, '[]'); +ERROR HY000: Invalid value for keyword items # End of 11.1 test diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index a1e52a0494c..3d9a8e3116b 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -3494,4 +3494,43 @@ SET @schema = '{ SELECT JSON_SCHEMA_VALID(@schema, '2'); +--echo # +--echo # MDEV-30704: JSON_SCHEMA_VALID: multipleOf must be greater than zero +--echo # + +SET @schema = '{ + "multipleOf": 0 + }'; +--error ER_JSON_INVALID_VALUE_FOR_KEYWORD +SELECT JSON_SCHEMA_VALID(@schema, '2'); + +SET @schema= '{ "maxLength" : -3}'; +--error ER_JSON_INVALID_VALUE_FOR_KEYWORD +SELECT JSON_SCHEMA_VALID(@schema, '2'); + +SET @schema= '{ "minLength" : -3}'; +--error ER_JSON_INVALID_VALUE_FOR_KEYWORD +SELECT JSON_SCHEMA_VALID(@schema, '2'); + +SET @schema= '{ "maxProperties" : -3}'; +--error ER_JSON_INVALID_VALUE_FOR_KEYWORD +SELECT JSON_SCHEMA_VALID(@schema, '2'); + +SET @schema= '{ "minProperties" : -3}'; +--error ER_JSON_INVALID_VALUE_FOR_KEYWORD +SELECT JSON_SCHEMA_VALID(@schema, '2'); + +SET @schema= '{ "maxItems" : -3}'; +--error ER_JSON_INVALID_VALUE_FOR_KEYWORD +SELECT JSON_SCHEMA_VALID(@schema, '2'); + +SET @schema= '{ "minItems" : -3}'; +--error ER_JSON_INVALID_VALUE_FOR_KEYWORD +SELECT JSON_SCHEMA_VALID(@schema, '2'); + +SET @schema= '{ "items" : ["str1"]}'; +--error ER_JSON_INVALID_VALUE_FOR_KEYWORD +SELECT JSON_SCHEMA_VALID(@schema, '[]'); + + --echo # End of 11.1 test |
