diff --git a/src/Interpreters/Aggregator.cpp b/src/Interpreters/Aggregator.cpp index 0d80adb6313..f0e64b5cbcf 100644 --- a/src/Interpreters/Aggregator.cpp +++ b/src/Interpreters/Aggregator.cpp @@ -1204,8 +1204,9 @@ void NO_INLINE Aggregator::executeImplBatch( inst->state_offset, [&](AggregateDataPtr & aggregate_data) { - aggregate_data = aggregates_pool->alignedAlloc(total_size_of_aggregate_states, align_aggregate_states); - createAggregateStates(aggregate_data); + AggregateDataPtr place = aggregates_pool->alignedAlloc(total_size_of_aggregate_states, align_aggregate_states); + createAggregateStates(place); + aggregate_data = place; }, state.getKeyData(), inst->batch_arguments, diff --git a/tests/queries/0_stateless/02963_msan_agg_addBatchLookupTable8.reference b/tests/queries/0_stateless/02963_msan_agg_addBatchLookupTable8.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/02963_msan_agg_addBatchLookupTable8.sql b/tests/queries/0_stateless/02963_msan_agg_addBatchLookupTable8.sql new file mode 100644 index 00000000000..a3a8bd0624a --- /dev/null +++ b/tests/queries/0_stateless/02963_msan_agg_addBatchLookupTable8.sql @@ -0,0 +1,2 @@ +-- https://github.com/ClickHouse/ClickHouse/issues/58727 +SELECT number % 2 AS even, aggThrow(number) FROM numbers(10) GROUP BY even; -- { serverError AGGREGATE_FUNCTION_THROW}