From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: steven.winfield@cantabcapital.com, PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value
Date: Fri, 2 Feb 2018 15:15:23 -0500
Message-ID: <bb65c62e-bb90-25a4-c993-b28facf5ff1e@2ndquadrant.com> (raw)
In-Reply-To: <20180202014939.GA31363@paquier.xyz>
References: <20171207112930.21696.79944@wrigleys.postgresql.org>
<12618e2c-0eb0-3e15-c45d-96891c52eb5f@2ndquadrant.com>
<CAB7nPqTMCmO_Y3HcQn9-oKFQBcWXckf24urAk+_ifBjfjhD0sA@mail.gmail.com>
<31740.1513222740@sss.pgh.pa.us>
<21a6da72-fb24-4b9e-d300-7439425f7492@2ndquadrant.com>
<CAB7nPqRMzeUqG2JHo81KTWz=gWGrkKbfLn2S3fOiMZ87JmVJ5w@mail.gmail.com>
<f1d4c6aa-d91b-ebc8-c249-17d7c847ac3b@2ndquadrant.com>
<12169.1514407385@sss.pgh.pa.us>
<20171230232601.GA4109@paquier.xyz>
<6a328b03-6912-2d12-2be6-387d4a1613c7@2ndquadrant.com>
<20180202014939.GA31363@paquier.xyz>
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
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: peter.eisentraut@2ndquadrant.com, michael.paquier@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value
In-Reply-To: <bb65c62e-bb90-25a4-c993-b28facf5ff1e@2ndquadrant.com>
References: <20171207112930.21696.79944@wrigleys.postgresql.org> <12618e2c-0eb0-3e15-c45d-96891c52eb5f@2ndquadrant.com> <CAB7nPqTMCmO_Y3HcQn9-oKFQBcWXckf24urAk+_ifBjfjhD0sA@mail.gmail.com> <31740.1513222740@sss.pgh.pa.us> <21a6da72-fb24-4b9e-d300-7439425f7492@2ndquadrant.com> <CAB7nPqRMzeUqG2JHo81KTWz=gWGrkKbfLn2S3fOiMZ87JmVJ5w@mail.gmail.com> <f1d4c6aa-d91b-ebc8-c249-17d7c847ac3b@2ndquadrant.com> <12169.1514407385@sss.pgh.pa.us> <20171230232601.GA4109@paquier.xyz> <6a328b03-6912-2d12-2be6-387d4a1613c7@2ndquadrant.com> <20180202014939.GA31363@paquier.xyz> <bb65c62e-bb90-25a4-c993-b28facf5ff1e@2ndquadrant.com>
* 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