Re: anonymous composite types for Table Functions (aka SRFs)
От | nconway@klamath.dyndns.org (Neil Conway) |
---|---|
Тема | Re: anonymous composite types for Table Functions (aka SRFs) |
Дата | |
Msg-id | 20020729145740.GA6685@klamath.dyndns.org обсуждение исходный текст |
Ответ на | anonymous composite types for Table Functions (aka SRFs) (Joe Conway <mail@joeconway.com>) |
Ответы |
Re: anonymous composite types for Table Functions (aka SRFs)
|
Список | pgsql-patches |
On Sun, Jul 28, 2002 at 10:24:34PM -0700, Joe Conway wrote: > Attached are two patches to implement and document anonymous composite > types for Table Functions, as previously proposed on HACKERS. Nice work! > 1. Creates a new pg_type typtype: 'p' for pseudo type (currently either > 'b' for base or 'c' for catalog, i.e. a class). I think you mentioned that typtype could be renamed to typkind -- that sounds good to me... > When creating a function you can do: > CREATE FUNCTION foo(text) RETURNS setof RECORD ... > > When using it you can do: > SELECT * from foo(sqlstmt) AS (f1 int, f2 text, f3 timestamp) Is there a reason why you can't specify the return type in the function declaration? ISTM that for most functions, the 'AS' clause will be the same for every usage of the function. On a related note, it is possible for the table function to examine the attributes it has been asked to return, right? Since the current patch requires that every call specify the return type, it might be possible to take advantage of that to provide semi-"polymorphic" behavior (i.e. the function behaves differently depending on the type of data the user asked for) > SELECT * from foo(sqlstmt) AS f(f1 int, f2 text, f3 timestamp) What does the 'f' indicate? > SELECT * from foo(sqlstmt) f(f1 int, f2 text, f3 timestamp) This form of the syntax seems a bit unclear, IMHO. It seems a bit like two function calls. Can the 'AS' be made mandatory? Cheers, Neil -- Neil Conway <neilconway@rogers.com> PGP Key ID: DB3C29FC
В списке pgsql-patches по дате отправления: