Strange aggregate

Поиск
Список
Период
Сортировка
От Teodor Sigaev
Тема Strange aggregate
Дата
Msg-id 3E7F3AA3.2050307@sigaev.ru
обсуждение исходный текст
Ответы Re: Strange aggregate  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi!


Is there possibility to write aggregate returns setof value?

I want to implement some statistic aggregate for tsearch:

....
create type statinfo as (word text, ndoc int4, nentry int4);

CREATE FUNCTION ts_accum(txtstat,txtidx)
RETURNS txtstat
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);

create function ts_accum_finish(txtstat)        returns setof statinfo        as 'MODULE_PATHNAME'        language 'C'
     with (isstrict);
 

CREATE AGGREGATE stat (        BASETYPE=txtidx,        SFUNC=ts_accum,        STYPE=txtstat,        FINALFUNC =
ts_accum_finish,       initcond = ''
 
);


and output like this:

# select * from ts_accum_finish(ts_accum('','qwer:1,2,3,345,65 sd:5,3 qwer:5,6,7')); word | ndoc | nentry
------+------+-------- sd   |    1 |      2 qwer |    1 |      8
(2 rows)

But any my tries gives:
# select stat(a) from test_txtidx;
ERROR:  function called in context that does not accept a set result

I know that is not right way to call setof functions, but how in this case?
Or give more simple way, pls...
Thank you.

Note, I'm working on tsearch V2, which isn't in CVS yet, only on our GiST page:
http://www.sai.msu.su/~megera/postgres/gist/

-- 
Teodor Sigaev                                  E-mail: teodor@sigaev.ru



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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: PQescapeBytea on Win32
Следующее
От: "Anand B Kumar"
Дата:
Сообщение: Re: Please clarify with regard to Renaming a Sequence