Re: [WIP] UNNEST(REFCURSOR): allowing SELECT to consume data from a REFCURSOR
"Daniel Verite" <[email protected]> Tue, 14 Jan 2020 15:53:37 +0100
| Newsgroups | gmane.comp.db.postgresql.devel.general |
|---|---|
| Message-ID | <[email protected]> |
Dent John wrote:
> It=E2=80=99s crashing when it=E2=80=99s checking that the returned tuple =
matches the
> declared return type in rsinfo->setDesc. Seems rsinfo->setDesc gets
> overwritten. So I think I have a memory management problem.
What is the expected result anyway? A single column with a "record"
type? FWIW I notice that with plpgsql, this is not allowed to happen:
CREATE FUNCTION cursor_unnest(x refcursor) returns setof record
as $$
declare
r record;
begin
loop
fetch x into r;
exit when not found;
return next r;
end loop;
end $$ language plpgsql;
begin;
declare c cursor for select oid::int as i, relname::text as r from pg_class;
select cursor_unnest('c');
ERROR: set-valued function called in context that cannot accept a set
CONTEXT: PL/pgSQL function cursor_unnest(refcursor) line 8 at RETURN NEXT
Best regards,
--=20
Daniel V=C3=A9rit=C3=A9
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite