Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ehhkE-00047Q-Re for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Feb 2018 20:15:34 +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 1ehhkD-0004ya-TN for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Feb 2018 20:15:33 +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 1ehhkD-0004yP-KF for pgsql-bugs@lists.postgresql.org; Fri, 02 Feb 2018 20:15:33 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ehhk6-0006bD-7i for pgsql-bugs@postgresql.org; Fri, 02 Feb 2018 20:15:32 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id BC98B21FDC; Fri, 2 Feb 2018 15:15:24 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Fri, 02 Feb 2018 15:15:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=lNEiUf n3HUiM0kntacqyHrpnSNGnr5RtY2u5Ltgd0x4=; b=h0kzbAVeAzD5Y98r01NLJg oA3E0U/m7C9P/0JvPHHrjnyuHdqqbHbJTz65He0bHnZ15u9lc8/XqknQzgoKLqQU 5a/6p5m2IIqAX26Msmcn3O27nHmdQzYku0HwA/ju4GptBrZibzXwZdUNS6x/NRwF TisFsfDlIpEnFKE2uT85FeEJrmZfH8op2+Ov3y+F13qYs/pH632QJBDCJJ10UIrs sOwsAoITAQ3NXgPcrtW8Ub+fyq+dltPhTElrOxJExnl22Ca+UNkZLXJFohq0gDPd lTgy4Gr4m+EMH6ylvXxxrgWQWPuDr4fTN+h/csSTZ+8qIOfB5aWFbjQ0TcQUHWzQ == X-ME-Sender: Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 74D7024519; Fri, 2 Feb 2018 15:15:24 -0500 (EST) Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value To: Michael Paquier 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> <12169.1514407385@sss.pgh.pa.us> <20171230232601.GA4109@paquier.xyz> <6a328b03-6912-2d12-2be6-387d4a1613c7@2ndquadrant.com> <20180202014939.GA31363@paquier.xyz> Cc: Tom Lane , steven.winfield@cantabcapital.com, PostgreSQL mailing lists From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Fri, 2 Feb 2018 15:15:23 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180202014939.GA31363@paquier.xyz> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2/1/18 20:49, Michael Paquier wrote: > Wrapping again my mind on this one... On top of the comment for > identitySequence, I think that it is important to mention that the > sequence name and a RangeVar are basically safe as they get created > hence they are not visible to other sessions yet. 0001 and 0002 should > be merged. Committed with more comments and as one patch. > By the way, on HEAD with two sessions it is easy to bump into sequence > name conflicts with identity columns: > * Session 1: > begin; > create table itest13 (a int); > * Session 2: > create sequence itest13_b_seq; > * Session 1: > alter table itest13 add columns b int generated by default as identity; --blocks > * Session 2: > commit; > > And then session 1 reports that: > ERROR: 23505: duplicate key value violates unique constraint "pg_type_typname_nsp_index" > DETAIL: Key (typname, typnamespace)=(itest13_b_seq, 2200) already exists. > SCHEMA NAME: pg_catalog > TABLE NAME: pg_type > CONSTRAINT NAME: pg_type_typname_nsp_index > LOCATION: _bt_check_unique, nbtinsert.c:434 I think this is equivalent to pre-existing behavior with serial: S1: begin; S2: begin; S2: create sequence t1_a_seq; S1: create table t1 (a serial, b text); --blocks S2: commit; S1: ERROR I suspect you can also construct situations like this with other implicitly created objects such as triggers. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services