AW: functions returning records

From: Zeugswetter Andreas SB <ZeugswetterA(at)wien(dot)spardat(dot)at>
To: "'Alex Pilosov'" <alex(at)pilosoft(dot)com>, Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: AW: functions returning records
Date: 2001-06-27 11:17:13
Message-ID: 11C1E6749A55D411A9670001FA687963368352@sdexcsrv1.f000.d0188.sd.spardat.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> > For the result from foo() you must somewhere define attributes (names).
> > Where? In CREATE FUNCTION statement? Possible must be:
> Function must be returning an existing reltype. I understand its a major
> restriction, but I can't think of a better way.

Yup, that's how Informix does it. It has a "create row type" command,
so you don't actually need a table.

>
> > select name1, name2 from foo() where name1 > 10;
> >
> > What returns foo()? ...the pointer to HeapTuple or something like this or
> > pointer to some temp table?
> Pointer to heaptuple. We can get to tupdesc for that tuple by looking up
> its prorettype.

But the question is how you get the next row. Do you return a null terminated
array of heaptuples ?

Imho to allow this to be efficient, there would need to be some mechanism,
that would allow the function to return the result in small blocks (e.g. each row)
(similar to a heap access), else you would be limited to return
values, that fit into memory, or fit on temporary disk storage, and do
work that might not even be required, because the client only fetches the
first row.

Andreas

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alex Pilosov 2001-06-27 11:21:17 Re: AW: AW: AW: functions returning records
Previous Message Zeugswetter Andreas SB 2001-06-27 11:03:46 AW: AW: AW: functions returning records