Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c8EMJ-0001Uk-C4 for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Nov 2016 22:43:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1c8EMI-0000qo-96 for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Nov 2016 22:43:42 +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.84_2) (envelope-from ) id 1c8EKs-0007Mo-07 for pgsql-hackers@postgreSQL.org; Sat, 19 Nov 2016 22:42:14 +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.84_2) (envelope-from ) id 1c8EKp-0004z1-J2 for pgsql-hackers@postgreSQL.org; Sat, 19 Nov 2016 22:42:12 +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 uAJMgAfP004309 for ; Sat, 19 Nov 2016 17:42:10 -0500 From: Tom Lane To: pgsql-hackers@postgreSQL.org Subject: Bogus use of *-expansion in UPDATE MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4307.1479595330.1@sss.pgh.pa.us> Date: Sat, 19 Nov 2016 17:42:10 -0500 Message-ID: <4308.1479595330@sss.pgh.pa.us> X-Pg-Spam-Score: -4.8 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org You get an odd result if you write "something.*" in an UPDATE's source expressions: regression=# create table t1 (f1 int, f2 int, f3 int); CREATE TABLE regression=# update t1 set f1 = t1.*; ERROR: UPDATE target count mismatch --- internal error The reason for that is that we use transformTargetList() to do parse analysis of the source expressions, and it thinks it should expand "t1.*" into "t1.f1, t1.f2, t1.f3" as we would do in a SELECT. This seems nonsensical to me: there is no way that there can be more than one source expression for a given target column. It would make sense to do *-expansion in this context: regression=# update t1 set (f1,f2,f3) = (t1.*); since that's implicitly a row constructor and we're supposed to do *-expansion in row constructors. Currently it doesn't work: ERROR: number of columns does not match number of values LINE 1: update t1 set (f1,f2,f3) = (t1.*); ^ which I think is a separate bug, or at least missing feature, in the multi-target-column feature. It would take a little work to fix that, since the expansion would have to wait till parse analysis, whereas currently we separate the column targets in gram.y. In short, I think we should modify transformTargetList so that it doesn't do *-expansion when processing a simple UPDATE SET expression. I'm not sufficiently motivated to rewrite the code enough to fix the second case right now, but the first case seems like a simple bug fix. I would expect UPDATE tab SET composite_column = foo.* to be capable of working, but right now it's busted. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers