mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 11:32:03 +00:00
Check for invalid regexp in JSON SKIP REGEXP section
This commit is contained in:
parent
39bc050e5f
commit
dfd17cc2d7
@ -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)
|
||||
|
4
tests/queries/0_stateless/03227_json_invalid_regexp.sql
Normal file
4
tests/queries/0_stateless/03227_json_invalid_regexp.sql
Normal 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};
|
||||
|
Loading…
Reference in New Issue
Block a user