personally they way I do it, is by creating temporary table, in transaction - and use it in function. Obviously that's very indirect, and not obvious if you see function's declaration. But works fine.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных