Re: Detecting change in event properties - Mailing list pgsql-general

From David Johnston
Subject Re: Detecting change in event properties
Date
Msg-id 1382737636849-5775977.post@n5.nabble.com
Whole thread Raw
In response to Re: Detecting change in event properties  (Elliot <yields.falsehood@gmail.com>)
List 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.


pgsql-general by date:

Previous
From: David Johnston
Date:
Subject: Re: Detecting change in event properties
Next
From: Patrick Dung
Date:
Subject: Re: (collation) Building postgresql on FreeBSD, the pros and cons of icu