Skip to content

Commit

Permalink
Merge pull request #54412 from ClickHouse/backport/23.3/54385
Browse files Browse the repository at this point in the history
Backport #54385 to 23.3: Check for overflow before addition in `analysisOfVariance` function
  • Loading branch information
antonio2368 committed Sep 11, 2023
2 parents d12863a + d6e97ea commit 5dc1611
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/AggregateFunctions/Moments.h
Expand Up @@ -459,6 +459,10 @@ struct AnalysisOfVarianceMoments

void add(T value, size_t group)
{
if (group == std::numeric_limits<size_t>::max())
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Too many groups for analysis of variance (should be no more than {}, got {})",
MAX_GROUPS_NUMBER, group);

resizeIfNeeded(group + 1);
xs1[group] += value;
xs2[group] += value * value;
Expand Down
Empty file.
@@ -0,0 +1 @@
SELECT analysisOfVariance(1, 18446744073709551615); -- { serverError BAD_ARGUMENTS }

0 comments on commit 5dc1611

Please sign in to comment.