From: | Teodor Sigaev <teodor(at)sigaev(dot)ru> |
---|---|
To: | Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Strange aggregate |
Date: | 2003-03-24 17:04:35 |
Message-ID: | 3E7F3AA3.2050307@sigaev.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)sigaev(dot)ru
From | Date | Subject | |
---|---|---|---|
Next Message | Neil Conway | 2003-03-24 17:17:29 | DEFAULT in <set clause list> |
Previous Message | Bruce Momjian | 2003-03-24 16:28:15 | Re: PQescapeBytea on Win32 |