aggregate returning anyarray and 'cannot determine result data type'
В списке pgsql-general по дате отправления:
| От | Tomas Vondra |
|---|---|
| Тема | aggregate returning anyarray and 'cannot determine result data type' |
| Дата | |
| Msg-id | 5356EC2E.3090900@fuzzy.cz обсуждение исходный текст |
| Список | pgsql-general |
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
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера