Justin Pryzby <pry...@telsasoft.com> writes: > On Sat, Apr 15, 2023 at 11:33:58AM +1200, David Rowley wrote: >> Any chance you could try and come up with a minimal reproducer?
> Try this Thanks. I see the problem: finalize_aggregate is no longer forcing a R/W expanded datum returned by the finalfn into R/O form. If we re-use the aggregate result in multiple places, as this query does, then the first use can clobber the value for later uses. (The commit message specifically mentions this concern, so I wonder how we failed to actually do it :-() A minimal fix would be to force to R/O before returning from finalize_aggregate, but I wonder if we should do it later. By the by, I couldn't help noticing that ExecAggTransReparent completely fails to do what its name promises it should do, ie reparent a R/W datum into the proper context instead of physically copying it. That looks suspiciously like something that got broken during some other refactoring somewhere along the line. That'd be a performance bug not a correctness bug, but it should be looked into. regards, tom lane