Avoid UBSan report in aggregate function sum

This commit is contained in:
Alexey Milovidov 2021-01-21 22:52:00 +03:00
parent dca0cbf4eb
commit d9cb1c1bdd
3 changed files with 5 additions and 1 deletions

View File

@ -148,7 +148,7 @@ class AggregateFunctionAvg final : public AggregateFunctionAvgBase<AvgFieldType<
public:
using AggregateFunctionAvgBase<AvgFieldType<T>, UInt64, AggregateFunctionAvg<T>>::AggregateFunctionAvgBase;
void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const final
void NO_SANITIZE_UNDEFINED add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const final
{
this->data(place).numerator += static_cast<const DecimalOrVectorCol<T> &>(*columns[0]).getData()[row_num];
++this->data(place).denominator;

View File

@ -0,0 +1 @@
4233720368547758080

View File

@ -0,0 +1,3 @@
-- Aggregate function 'sum' allows overflow with two's complement arithmetics.
-- This contradicts the standard SQL semantic and we are totally fine with it.
SELECT sum(-8000000000000000000) FROM numbers(11);