Re: The Axe list - Mailing list pgsql-hackers

From Robert Haas
Subject Re: The Axe list
Date
Msg-id 603c8f070810101826o678a71aamadcd2f9615b7d481@mail.gmail.com
Whole thread Raw
In response to The Axe list  (Josh Berkus <josh@agliodbs.com>)
Responses Re: The Axe list
List pgsql-hackers
> intagg: the aggregation function has been obsolete since 7.4 because
> standard array functionality supports the same.  intagg has a nice
> equivalent for UNROLL, but it only works for arrays of INT, and only
> one-dimensional arrays.  Has not been updated since 2001.

I think this one can be dropped.  The definition of a general
array_accum() is very easy, and supplied in the docs:

CREATE AGGREGATE array_accum (anyelement)
(   sfunc = array_append,   stype = anyarray,   initcond = '{}'
);

A general one-dimensional array enumerator is equally easy to define,
though not in the docs (there is a two-dimensional array enumerator
called unnest2 under generate_subscripts):

CREATE OR REPLACE FUNCTION array_enum(anyarray)   RETURNS SETOF anyelement AS
$$   SELECT $1[i] FROM generate_subscripts($1,1) i
$$ LANGUAGE sql;

With a little more work you could even (crazy thought) add some error checking.

It would probably be helpful if the generate_subscripts and array
documentation were cross-referenced a bit better.  There's no
indication on the array page that generate_subscripts() is out there,
and it's clearly both very useful and array-related.

...Robert


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: \ef should probably append semicolons
Next
From: Tom Lane
Date:
Subject: Re: The Axe list