From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Florian Pflug <fgp(at)phlo(dot)org> |
Cc: | PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Confusing documentation of ordered-set aggregates? |
Date: | 2014-01-23 03:56:57 |
Message-ID: | 28667.1390449417@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I wrote:
> Florian Pflug <fgp(at)phlo(dot)org> writes:
>> array_agg(), for example, also has a result type that is
>> determined by the argument type, yet it's final function doesn't take an
>> argument of type anyelement, even though it returns anyarray.
> Yeah. So it's a complete leap of faith on the type system's part that
> this function is an appropriate final function for array_agg(). I'm
> not sure offhand if CREATE AGGREGATE would even allow this combination
> to be created, or if it only works because we manually jammed those rows
> into the catalogs at initdb time. But it would certainly be safer if
> CREATE AGGREGATE *didn't* allow it.
Actually, after a little bit of experimentation, the irreproducible
manual catalog hack is the very existence of array_agg_finalfn().
If you try to reproduce it via CREATE FUNCTION, the system will object:
regression=# create function foo(internal) returns anyarray as
regression-# 'array_agg_finalfn' language internal;
ERROR: cannot determine result data type
DETAIL: A function returning a polymorphic type must have at least one polymorphic argument.
So what the ordered-set-aggregate patch has done is introduce a principled
way to define polymorphic aggregates with non-polymorphic state types,
something we didn't have before.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | KONDO Mitsumasa | 2014-01-23 04:33:06 | Re: Add min and max execute statement time in pg_stat_statement |
Previous Message | Tom Lane | 2014-01-23 03:30:14 | Re: Confusing documentation of ordered-set aggregates? |