Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fSkjI-00024z-16 for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Jun 2018 14:57:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fSkjG-0004ao-SK for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Jun 2018 14:57:02 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fSkjG-0004aY-Im for pgsql-bugs@lists.postgresql.org; Tue, 12 Jun 2018 14:57:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fSkjD-0003i7-RV for pgsql-bugs@lists.postgresql.org; Tue, 12 Jun 2018 14:57:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w5CEuuBW030686; Tue, 12 Jun 2018 10:56:57 -0400 From: Tom Lane To: Andrew Gierth cc: 110876189@qq.com, 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" 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> Comments: In-reply-to Andrew Gierth message dated "Tue, 12 Jun 2018 11:28:38 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30684.1528815416.1@sss.pgh.pa.us> Date: Tue, 12 Jun 2018 10:56:56 -0400 Message-ID: <30685.1528815416@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andrew Gierth writes: > "Tom" == Tom Lane 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