Re: The Axe list

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: The Axe list
Дата
Msg-id 603c8f070810101826o678a71aamadcd2f9615b7d481@mail.gmail.com
обсуждение исходный текст
Ответ на The Axe list  (Josh Berkus <josh@agliodbs.com>)
Ответы Re: The Axe list  (Gregory Stark <stark@enterprisedb.com>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: \ef should probably append semicolons
Следующее
От: Tom Lane
Дата:
Сообщение: Re: The Axe list