diff --git a/dbms/include/DB/AggregateFunctions/IAggregateFunction.h b/dbms/include/DB/AggregateFunctions/IAggregateFunction.h index bed901d187d..4d76a35139a 100644 --- a/dbms/include/DB/AggregateFunctions/IAggregateFunction.h +++ b/dbms/include/DB/AggregateFunctions/IAggregateFunction.h @@ -59,7 +59,7 @@ public: virtual void create(AggregateDataPtr place) const = 0; /// Уничтожить данные для агрегации. - virtual void destroy(AggregateDataPtr place) const = 0; + virtual void destroy(AggregateDataPtr place) const noexcept = 0; /// Уничтожать данные не обязательно. virtual bool hasTrivialDestructor() const = 0; @@ -118,7 +118,7 @@ public: new (place) Data; } - void destroy(AggregateDataPtr place) const + void destroy(AggregateDataPtr place) const noexcept { data(place).~Data(); } diff --git a/dbms/src/Interpreters/Aggregator.cpp b/dbms/src/Interpreters/Aggregator.cpp index 04e441d0949..ad28e2086a7 100644 --- a/dbms/src/Interpreters/Aggregator.cpp +++ b/dbms/src/Interpreters/Aggregator.cpp @@ -265,14 +265,15 @@ void Aggregator::mergeDataImpl( if (!inserted) { for (size_t i = 0; i < aggregates_size; ++i) - { aggregate_functions[i]->merge( Method::getAggregateData(res_it->second) + offsets_of_aggregate_states[i], Method::getAggregateData(it->second) + offsets_of_aggregate_states[i]); + for (size_t i = 0; i < aggregates_size; ++i) aggregate_functions[i]->destroy( Method::getAggregateData(it->second) + offsets_of_aggregate_states[i]); - } + + Method::getAggregateData(it->second) = nullptr; } else { @@ -668,10 +669,10 @@ AggregatedDataVariantsPtr Aggregator::merge(ManyAggregatedDataVariants & data_va AggregatedDataWithoutKey & current_data = current.without_key; for (size_t i = 0; i < aggregates_size; ++i) - { aggregate_functions[i]->merge(res_data + offsets_of_aggregate_states[i], current_data + offsets_of_aggregate_states[i]); + + for (size_t i = 0; i < aggregates_size; ++i) aggregate_functions[i]->destroy(current_data + offsets_of_aggregate_states[i]); - } } if (res->type == AggregatedDataVariants::KEY_64)