On 15/12/2021, at 11:51 AM, Tom Lane <t...@sss.pgh.pa.us> wrote: > You should > probably palloc temp arrays right here and then use construct_md_array > directly instead of dealing with an ArrayBuildState.
OK, I gave that a go [1] this time in a vec_agg_sum() aggregate, that operates much the same as the vec_agg_mean() one and is behaving in the same way. For example this shows the correct values: SELECT vec_agg_sum(nums) FROM measurements; NOTICE: sum 0 = 4.92 NOTICE: sum 1 = 5.91 NOTICE: sum 2 = 14.80 vec_agg_sum ------------------- {4.92,5.91,14.80} (1 row) But adding unnest() goes back to seemingly memory address values: SELECT unnest(vec_agg_sum(nums)) FROM measurements; NOTICE: sum 0 = 4.92 NOTICE: sum 1 = 5.91 NOTICE: sum 2 = 14.80 unnest ---------------- 94069010663032 94069010663044 94069010663056 (3 rows) Any other ideas I could look into? — m@ [1] https://github.com/SolarNetwork/aggs_for_vecs/blob/df8b950c73d9b32fa6f016b44dd8859e9341fe0f/vec_agg_sum.c#L50-L52 <https://github.com/SolarNetwork/aggs_for_vecs/blob/df8b950c73d9b32fa6f016b44dd8859e9341fe0f/vec_agg_sum.c#L50-L52>