diff options
Diffstat (limited to 'sql/json_schema.cc')
-rw-r--r-- | sql/json_schema.cc | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/sql/json_schema.cc b/sql/json_schema.cc index d0bb162cefe..7956ae49fff 100644 --- a/sql/json_schema.cc +++ b/sql/json_schema.cc @@ -774,7 +774,7 @@ bool Json_schema_multiple_of::validate(const json_engine_t *je, double val= je->s.cs->strntod((char *) je->value, je->value_len, &end, &err); - double temp= val / this->value; + double temp= val / multiple_of; bool res= (temp - (long long int)temp) == 0; return !res; @@ -797,12 +797,12 @@ bool Json_schema_multiple_of::handle_keyword(THD *thd, json_engine_t *je, double val= je->s.cs->strntod((char *) je->value, je->value_len, &end, &err); - if (val < 0) + if (val <= 0) { my_error(ER_JSON_INVALID_VALUE_FOR_KEYWORD, MYF(0), "multipleOf"); return true; } - value= val; + multiple_of= val; return false; } @@ -834,8 +834,11 @@ bool Json_schema_max_len::handle_keyword(THD *thd, json_engine_t *je, double val= je->s.cs->strntod((char *) je->value, je->value_len, &end, &err); if (val < 0) + { my_error(ER_JSON_INVALID_VALUE_FOR_KEYWORD, MYF(0), "maxLength"); - value= val; + return true; + } + value= (int)val; return false; } @@ -869,9 +872,17 @@ bool Json_schema_min_len::handle_keyword(THD *thd, json_engine_t *je, if (val < 0) { my_error(ER_JSON_INVALID_VALUE_FOR_KEYWORD, MYF(0), "minLength"); +<<<<<<< HEAD return true; } value= val; +||||||| parent of 203f63d7bf1... MDEV-30704: JSON_SCHEMA_VALID: multipleOf must be greater than zero + value= val; +======= + return true; + } + value= (int)val; +>>>>>>> 203f63d7bf1... MDEV-30704: JSON_SCHEMA_VALID: multipleOf must be greater than zero return false; } @@ -982,8 +993,11 @@ bool Json_schema_max_items::handle_keyword(THD *thd, json_engine_t *je, double val= je->s.cs->strntod((char *) je->value, je->value_len, &end, &err); if (val < 0) + { my_error(ER_JSON_INVALID_VALUE_FOR_KEYWORD, MYF(0), "maxItems"); - value= val; + return true; + } + value= (int)val; return false; } @@ -1037,7 +1051,7 @@ bool Json_schema_min_items::handle_keyword(THD *thd, json_engine_t *je, my_error(ER_JSON_INVALID_VALUE_FOR_KEYWORD, MYF(0), "maxLength"); return true; } - value= val; + value= (int)val; return false; } @@ -1279,9 +1293,14 @@ bool Json_schema_prefix_items::handle_keyword(THD *thd, json_engine_t *je, char *begin, *end; int len; - if (json_read_value(je)) - return true; - begin= (char*)je->value; + if (json_read_value(je)) + return true; + if (je->value_type != JSON_VALUE_OBJECT) + { + my_error(ER_JSON_INVALID_VALUE_FOR_KEYWORD, MYF(0), "items"); + return true; + } + begin= (char*)je->value; if (json_skip_level(je)) return true; @@ -1452,7 +1471,7 @@ bool Json_schema_max_prop::handle_keyword(THD *thd, json_engine_t *je, my_error(ER_JSON_INVALID_VALUE_FOR_KEYWORD, MYF(0), "maxProperties"); return true; } - value= val; + value= (int)val; return false; } @@ -1511,7 +1530,7 @@ bool Json_schema_min_prop::handle_keyword(THD *thd, json_engine_t *je, my_error(ER_JSON_INVALID_VALUE_FOR_KEYWORD, MYF(0), "minProperties"); return true; } - value= val; + value= (int)val; return false; } |