Re: an aggregate array function

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: an aggregate array function
Дата
Msg-id 3F2683E1.3030602@joeconway.com
обсуждение исходный текст
Ответ на Re: an aggregate array function  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
Список pgsql-hackers
Merlin Moncure wrote:
> What do you think about the other question about an
> 'array creating aggregate', is that a useful contribution?
> 

Hmm, either I'm not understanding you, or you're not understanding me ;-)

First, see contrib/intagg.
Second, the following works in 7.4devel:

-- create test data for polymorphic aggregates
create table t(f1 int, f2 float, f3 float);
insert into t values(1,11.1,21.1);
insert into t values(1,11.2,21.2);
insert into t values(1,11.3,21.3);
insert into t values(2,12.1,22.1);
insert into t values(2,12.2,22.2);
insert into t values(2,12.3,22.3);
insert into t values(3,13.1,23.1);
insert into t values(3,13.2,23.2);

CREATE AGGREGATE myagg1
(  BASETYPE = float8,  SFUNC = array_append,  STYPE = float8[],  INITCOND = '{}'
);

CREATE AGGREGATE myagg2
(  BASETYPE = float8[],  SFUNC = array_cat,  STYPE = float8[],  INITCOND = '{}'
);

regression=# select f1, myagg1(f2) from t group by f1; f1 |      myagg1
----+------------------  3 | {13.1,13.2}  2 | {12.1,12.2,12.3}  1 | {11.1,11.2,11.3}
(3 rows)

regression=# select f1, myagg2(array[f2,f3]) from t group by f1; f1 |                myagg2
----+---------------------------------------  3 | {{13.1,23.1},{13.2,23.2}}  2 | {{12.1,22.1},{12.2,22.2},{12.3,22.3}}
1| {{11.1,21.1},{11.2,21.2},{11.3,21.3}}
 
(3 rows)

Joe



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Carlos Guzman Alvarez
Дата:
Сообщение: Re: Passing server_encoding to the client is not future-proof
Следующее
От: Robert Treat
Дата:
Сообщение: Re: is 7.3.4 final?