From: Tom Lane <tgl@sss.pgh.pa.us>
To: Neil Conway <neil.conway@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: row_to_json(), NULL values, and AS
Date: Fri, 15 Jun 2018 10:53:13 -0400
Message-ID: <32582.1529074393@sss.pgh.pa.us> (raw)
In-Reply-To: <18365.1529018904@sss.pgh.pa.us>
References: <CAOW5sYa3Wp7KozCuzjOdw6PiOYPi6D=VvRybtH2S=2C0SVmRmA@mail.gmail.com>
<18365.1529018904@sss.pgh.pa.us>
I wrote:
> Neil Conway <neil.conway@gmail.com> writes:
>> The following behavior does not seem self-consistent to me:
> Likewise.
Oh! What is actually happening is
(1) With no explicit alias, the column name of the sub-select's second
output column is chosen to be "row_to_json".
(2) That makes the outer query's notation row_to_json(x) ambiguous: it
could be a function-syntax reference to the column x.row_to_json.
(3) As it happens, the column interpretation is chosen when it's
ambiguous (cf ParseComplexProjection).
I'm a bit hesitant to muck with this behavior, given that it's stood
for ~20 years. However, if we did want to touch it, maybe the right
thing would be to give up the absolutist position that f(x) and x.f
are exactly interchangeable. We could say instead that we prefer the
function interpretation if function syntax is used, and the column
interpretation if column syntax is used. I don't know how likely
that is to break existing apps ... perhaps not very, but I wouldn't
risk back-patching it in any case.
regards, tom lane
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, neil.conway@gmail.com
Subject: Re: row_to_json(), NULL values, and AS
In-Reply-To: <32582.1529074393@sss.pgh.pa.us>
References: <CAOW5sYa3Wp7KozCuzjOdw6PiOYPi6D=VvRybtH2S=2C0SVmRmA@mail.gmail.com> <18365.1529018904@sss.pgh.pa.us> <32582.1529074393@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox