From: | Tomas Vondra <tv(at)fuzzy(dot)cz> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | aggregate returning anyarray and 'cannot determine result data type' |
Date: | 2014-04-22 22:24:46 |
Message-ID: | 5356EC2E.3090900@fuzzy.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
Hi all,
I needed to implement an aggregate producing a random sample, with an
upper bound on the number of items. I.e. not the usual "5% of values"
but "up to 1000 values".
So my plan was to do something like this:
sample_append(internal, anyelement, int) -> internal
sample_final(internal) -> anyarray
CREATE AGGREGATE sample_agg(anyelement, int) (
SFUNC = sample_append,
STYPE = internal,
FINALFUNC = sample_final
);
where 'internal' represents a pointer to a structure with all the info
(limit, currently accumulated sample, ...).
However this leads to
ERROR: cannot determine result data type
DETAIL: A function returning a polymorphic type must have at least
one polymorphic argument
because 'sample_final' produces anyarray but has no polymorphic
argument. Sadly, the 'natural' solution of using anyarray instead of the
internal structure does not work because I have no way to pass the other
parameters to the final function (the last int in sfunc).
Any ideas how to solve this?
regards
Tomas
From | Date | Subject | |
---|---|---|---|
Next Message | Wells Oliver | 2014-04-22 22:52:19 | Using 9.3 as a slave to 9.1 for upgrade purposes |
Previous Message | Craig Libscomb | 2014-04-22 21:05:22 | Re: Can't delete role because of unknown object |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2014-04-22 22:32:30 | Re: Re: default opclass for jsonb (was Re: Call for GIST/GIN/SP-GIST opclass documentation) |
Previous Message | Bruce Momjian | 2014-04-22 22:23:19 | Re: MultiXactId error after upgrade to 9.3.4 |