From: | David Johnston <polobo(at)yahoo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Detecting change in event properties |
Date: | 2013-10-25 21:47:16 |
Message-ID: | 1382737636849-5775977.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Elliot wrote
> Maybe a custom aggregate that takes the last item in a set?
>
> CREATE OR REPLACE FUNCTION public.last_agg ( anyelement, anyelement )
> RETURNS anyelement LANGUAGE sql IMMUTABLE STRICT AS $$
> SELECT $2;
> $$;
>
> CREATE AGGREGATE public.last (
> sfunc = public.last_agg,
> basetype = anyelement,
> stype = anyelement
> );
Conceptually similar to my array_last_nonnull(array_agg(...)) methodology
and the GUC methodology but has the advantage of saving minimal state
(compared to the array_agg()) and not abusing GUC for storage of the
single-value state.
The example would need the same alteration to the frame clause but otherwise
would appear to work in the manner presumed by the OP's original question.
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/Detecting-change-in-event-properties-tp5775959p5775977.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
From | Date | Subject | |
---|---|---|---|
Next Message | Patrick Dung | 2013-10-26 04:57:02 | Re: (collation) Building postgresql on FreeBSD, the pros and cons of icu |
Previous Message | David Johnston | 2013-10-25 21:35:36 | Re: Detecting change in event properties |