Re: select into composite type / return - Mailing list pgsql-sql

From Tom Lane
Subject Re: select into composite type / return
Date
Msg-id 3718235.1616077713@sss.pgh.pa.us
Whole thread Raw
In response to Re: select into composite type / return  (Torsten Grust <torsten.grust@gmail.com>)
Responses Re: select into composite type / return  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
List pgsql-sql
Torsten Grust <torsten.grust@gmail.com> writes:
> Hi Gary,
> a shot in the dark but maybe

> SELECT id, (do_breakdown(id)).*
> FROM   ...

> already does the job?

Beware --- what that actually does is expand into

SELECT id, (do_breakdown(id)).f1, (do_breakdown(id)).f2, ...

so that the function will be invoked N times if it produces N columns.

What you generally want to do is invoke the function as a lateral FROM
item:

SELECT id, f.* FROM table AS t, LATERAL do_breakdown(t.id) AS f;

            regards, tom lane



pgsql-sql by date:

Previous
From: Gary Stainburn
Date:
Subject: Re: select into composite type / return
Next
From: Gary Stainburn
Date:
Subject: Re: select into composite type / return