Fixed erroneus failure of extractAllGroupsHorizontal on large columns

This commit is contained in:
Vasily Nemkov 2021-04-13 13:50:58 +03:00
parent 305d3d6b16
commit 77bdb5b391
2 changed files with 7 additions and 5 deletions

View File

@ -172,11 +172,12 @@ public:
for (size_t group = 1; group <= groups_count; ++group)
all_matches.push_back(matched_groups[group]);
/// Additional limit to fail fast on supposedly incorrect usage.
static constexpr size_t MAX_GROUPS_PER_ROW = 1000000;
if (all_matches.size() > MAX_GROUPS_PER_ROW)
throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Too large array size in the result of function {}", getName());
/// Additional limit to fail fast on supposedly incorrect usage, aribtrary value.
static constexpr size_t MAX_MATCHES_PER_ROW = 1000;
if (matches_per_row > MAX_MATCHES_PER_ROW)
throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE,
"Too many matches per row (> {}) in the result of function {}",
MAX_MATCHES_PER_ROW, getName());
pos = matched_groups[0].data() + std::max<size_t>(1, matched_groups[0].size());

View File

@ -1 +1,2 @@
SELECT repeat('abcdefghijklmnopqrstuvwxyz', number * 100) AS haystack, extractAllGroupsHorizontal(haystack, '(\\w)') AS matches FROM numbers(1023); -- { serverError 128 }
SELECT count(extractAllGroupsHorizontal(materialize('a'), '(a)')) FROM numbers(1000000) FORMAT Null; -- shouldn't fail