Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUIXj-0007Sw-TY for pgsql-bugs@arkaria.postgresql.org; Wed, 27 Dec 2017 20:43:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUIXj-0002CT-Ak for pgsql-bugs@arkaria.postgresql.org; Wed, 27 Dec 2017 20:43:15 +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 1eUIXj-0002CJ-26 for pgsql-bugs@lists.postgresql.org; Wed, 27 Dec 2017 20:43:15 +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 1eUIXg-0002xS-OS for pgsql-bugs@postgresql.org; Wed, 27 Dec 2017 20:43:13 +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 vBRKh5WL012170; Wed, 27 Dec 2017 15:43:05 -0500 From: Tom Lane To: Peter Eisentraut cc: Michael Paquier , steven.winfield@cantabcapital.com, PostgreSQL mailing lists Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value In-reply-to: References: <20171207112930.21696.79944@wrigleys.postgresql.org> <12618e2c-0eb0-3e15-c45d-96891c52eb5f@2ndquadrant.com> <31740.1513222740@sss.pgh.pa.us> <21a6da72-fb24-4b9e-d300-7439425f7492@2ndquadrant.com> Comments: In-reply-to Peter Eisentraut message dated "Wed, 27 Dec 2017 15:01:37 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12168.1514407385.1@sss.pgh.pa.us> Date: Wed, 27 Dec 2017 15:43:05 -0500 Message-ID: <12169.1514407385@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter Eisentraut writes: > On 12/18/17 00:49, Michael Paquier wrote: >> In my opinion, this ALTER TABLE handling should be done by treating >> identity columns a way similar to default expressions in >> transformColumnDefinition(), by storing the FuncExpr node at parsing >> time instead of storing the information needed to rebuild it when >> executing the query. In short the mapping should get closer to what >> default does with nextval or serial. > The serial case works because it stores the sequence *name* in the > default value in the catalog. Just to clarify: what's *actually* stored for a regular serial column is the sequence OID (as a regclass constant), not the name. If it were a name then ALTER SEQUENCE RENAME would break it. > That doesn't work because for the > identity case we don't store the expression in the catalog. The > proposed patch works by storing the sequence *name* in the internal > structures so that it can be used in place of the stored default value. I trust you really mean you're storing an OID ... regards, tom lane