Check for invalid regexp in JSON SKIP REGEXP section

This commit is contained in:
avogar 2024-08-16 13:23:57 +00:00
parent 39bc050e5f
commit dfd17cc2d7
3 changed files with 15 additions and 0 deletions

View File

@ -49,6 +49,17 @@ DataTypeObject::DataTypeObject(
, max_dynamic_paths(max_dynamic_paths_)
, max_dynamic_types(max_dynamic_types_)
{
/// Check if regular expressions are valid.
for (const auto & regexp_str : path_regexps_to_skip)
{
re2::RE2::Options options;
/// Don't log errors to stderr.
options.set_log_errors(false);
auto regexp = re2::RE2(regexp_str, options);
if (!regexp.error().empty())
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Invalid regexp '{}': {}", regexp_str, regexp.error());
}
for (const auto & [typed_path, type] : typed_paths)
{
for (const auto & path_to_skip : paths_to_skip)

View File

@ -0,0 +1,4 @@
set allow_experimental_json_type = 1;
create table test (json JSON(SKIP REGEXP '[]')) engine=Memory(); -- {serverError BAD_ARGUMENTS}
create table test (json JSON(SKIP REGEXP '+')) engine=Memory(); -- {serverError BAD_ARGUMENTS};