From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: 110876189@qq.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15237: I got "ERROR: source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression"
Date: Tue, 12 Jun 2018 10:56:56 -0400
Message-ID: <30685.1528815416@sss.pgh.pa.us> (raw)
In-Reply-To: <87r2lctidw.fsf@news-spur.riddles.org.uk>
References: <152876885706.32361.1270737678956483321@wrigleys.postgresql.org>
<22079.1528774703@sss.pgh.pa.us>
<87r2lctidw.fsf@news-spur.riddles.org.uk>
Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:
> Tom> It's telling you what to do: use a ROW() expression, ie
> Tom> update fvt_obj_operate_update_table_033 set (c_int) = row(20)
> Tom> where c_int = 20;
> Yeah, but (a) this used to work, and has worked since at least as far
> back as 9.0, and (b) the spec requires it to work.
As far as (a) goes, it was an intentional compatibility breakage,
cf commits 86182b189 and 906bfcad7, and as for (b), the SQL committee
is just nuts here. They've overloaded the syntax to the point where
it's unresolvable if you try to allow everything the spec suggests
should be allowed. The expectation in 906bfcad7 was that we'd move
towards the *other* thing the spec demands, namely that the RHS can
be any a_expr yielding a suitable row value. We can't do that if
it's unclear what is or isn't a ROW() expression, because then the
intended semantics would be undecidable. And I don't think we want
a situation in which adding "extra" parens changes a legal command
into an illegal one. For example, suppose f(...) returns a single-column
tuple result. This should be legal, if x matches the type of the single
column:
update ... set (x) = f(...)
but if we try to do what you seem to have in mind, this would not be:
update ... set (x) = (f(...))
That's sufficiently brain-dead that I don't think we want to go there.
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, andrew@tao11.riddles.org.uk, 110876189@qq.com
Subject: Re: BUG #15237: I got "ERROR: source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression"
In-Reply-To: <30685.1528815416@sss.pgh.pa.us>
References: <152876885706.32361.1270737678956483321@wrigleys.postgresql.org> <22079.1528774703@sss.pgh.pa.us> <87r2lctidw.fsf@news-spur.riddles.org.uk> <30685.1528815416@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