public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Robert Haas <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: ExecTypeSetColNames is fundamentally broken
Date: Tue, 07 Dec 2021 12:30:48 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+Tgmoa2Fm+4eDb6O4NFzA-u78k2Wa0-V48qimSVgBbCF2MvDg@mail.gmail.com>
References: <[email protected]>
<CA+TgmoaYDAqLLmxo_d9h2SZ1Mw28M9w5QZMuZcaL6D2JdG_B6w@mail.gmail.com>
<[email protected]>
<CA+Tgmoa2Fm+4eDb6O4NFzA-u78k2Wa0-V48qimSVgBbCF2MvDg@mail.gmail.com>
Robert Haas <[email protected]> writes:
> On Mon, Dec 6, 2021 at 4:05 PM Tom Lane <[email protected]> wrote:
>> select f(t) from t(x,y);
>>
>> If we adopt the "rename for all purposes" interpretation, then
>> the second SELECT must fail, because what f() is being passed is
>> no longer of type t.
> For me, the second SELECT does fail:
> rhaas=# select f(t) from t(x,y);
> ERROR: column "x" does not exist
Ah, sorry, I fat-fingered the alias syntax. Here's a tested example:
regression=# create table t (a int, b int);
CREATE TABLE
regression=# insert into t values(11,12);
INSERT 0 1
regression=# create function f(t) returns int as 'select $1.a' language sql;
CREATE FUNCTION
regression=# select f(t) from t as t(x,y);
f
----
11
(1 row)
If we consider that the alias renames the columns "for all purposes",
how is it okay for f() to select the "a" column?
Another way to phrase the issue is that the column names seen
by f() are currently different from those seen by row_to_json():
regression=# select row_to_json(t) from t as t(x,y);
row_to_json
-----------------
{"x":11,"y":12}
(1 row)
and that seems hard to justify.
regards, tom lane
view thread (9+ messages) latest in thread
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], [email protected]
Subject: Re: ExecTypeSetColNames is fundamentally broken
In-Reply-To: <[email protected]>
* 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