Re: Properly handling aggregate in nested function call

Matt Magoffin <postgresql.org@msqr.us>

From: Matt Magoffin <postgresql.org@msqr.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@lists.postgresql.org
Date: 2021-12-16T02:11:12Z
Lists: pgsql-general
On 16/12/2021, at 2:43 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Of course what this function is actually returning is numeric[].
> There is some code such as array_out that will look at the
> element type OID embedded in the array value, and do the right
> thing.  But other code will believe the function's declared
> result type, and that sort of code will go wrong.

(Hand slap to face!) Oh my, thank you for spotting that, this has been driving me to distraction, thinking I was doing something wrong with memory contexts or anything other than that copy/paste error.

> Alternatively you can declare one set of polymorphic
> functions and aggregates, in which case you'll need to closely
> study the stuff about the finalfunc_extra option [2].

Thanks for the tips, I have been eyeing that documentation.

— m@