public inbox for [email protected]
help / color / mirror / Atom feedFrom: David G. Johnston <[email protected]>
To: Ron Johnson <[email protected]>
Cc: pgsql-general <[email protected]>
Subject: Re: Specifying columns returned by a function, when the function is in a SELECT column list?
Date: Tue, 19 Nov 2024 08:55:39 -0700
Message-ID: <CAKFQuwbFBn6uV1qczBXOZjd0r=zeH9s1KN4CQD_Nj=Lg17_GLQ@mail.gmail.com> (raw)
In-Reply-To: <CANzqJaBWNharGuTCY1OCzgU7S5zOCdKS84fCW=X8=AiVy1ibyg@mail.gmail.com>
References: <CANzqJaBWNharGuTCY1OCzgU7S5zOCdKS84fCW=X8=AiVy1ibyg@mail.gmail.com>
On Tue, Nov 19, 2024 at 8:48 AM Ron Johnson <[email protected]> wrote:
> It's trivial to specify columns when a table-returning function is the
> FROM clause, but how does one specify columns when the table-returning
> function is a column in a SELECT clause?
>
You don't/cannot. And with lateral you shouldn't find the need to hack
around it either. Non-scalar function calls in the select clause are now
obsolete.
In the select clause the function call returns a single-column of composite
type with the names of the fields in the composite already known. As the
query scope where you invoke the function you should only use the
composite. If you need to dive into its fields you'd need a subquery -
ideally one that doesn't risk being optimized away due to a
multiple-evaluation hazard.
David J.
view thread (2+ messages)
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: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Specifying columns returned by a function, when the function is in a SELECT column list?
In-Reply-To: <CAKFQuwbFBn6uV1qczBXOZjd0r=zeH9s1KN4CQD_Nj=Lg17_GLQ@mail.gmail.com>
* 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