Re: The Axe list

From: "Robert Haas" <robertmhaas(at)gmail(dot)com>
To: "Josh Berkus" <josh(at)agliodbs(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: The Axe list
Date: 2008-10-11 01:26:41
Message-ID: 603c8f070810101826o678a71aamadcd2f9615b7d481@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2008-10-11 02:37:20 patch: array_ndims
Previous Message Tom Lane 2008-10-11 01:26:31 Re: The Axe list