agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Tom Lane <tgl@sss.pgh.pa.us>
To: Torsten Grust <torsten.grust@gmail.com>
Cc: pgsql-sql <pgsql-sql@lists.postgresql.org>
Cc: Gary Stainburn <gary.stainburn@ringways.co.uk>
Subject: Re: select into composite type / return
Date: Thu, 18 Mar 2021 10:28:33 -0400
Message-ID: <3718235.1616077713@sss.pgh.pa.us> (raw)
In-Reply-To: <CAGqkgphmj3uHB3Jc5Eb=yA2cfffHFsACWR3Fbfr6jrkQepKJPA@mail.gmail.com>
References: <39dcfab9-4eb2-382b-9186-baf722ca56a0@ringways.co.uk>
<3523853.1616002010@sss.pgh.pa.us>
<9eb42b06-9cfa-1e4b-e42b-6f64e99675a5@ringways.co.uk>
<7af5d693-a6a3-d3d4-050a-0898aad8bd77@ringways.co.uk>
<CAGqkgphmj3uHB3Jc5Eb=yA2cfffHFsACWR3Fbfr6jrkQepKJPA@mail.gmail.com>
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
view thread (14+ messages) latest in thread
Message-ID: <3718235.1616077713@sss.pgh.pa.us>
Permalink: ../3718235.1616077713@sss.pgh.pa.us/
Also on: postgresql.org/message-id/3718235.1616077713@sss.pgh.pa.us
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, torsten.grust@gmail.com, pgsql-sql@lists.postgresql.org, gary.stainburn@ringways.co.uk
Subject: Re: select into composite type / return
In-Reply-To: <3718235.1616077713@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox