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 1ehQUE-0003rf-Th for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Feb 2018 01:49:55 +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 1ehQUD-0001zL-Kc for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Feb 2018 01:49:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ehQUD-0001zB-Bo for pgsql-bugs@lists.postgresql.org; Fri, 02 Feb 2018 01:49:53 +0000 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ehQUA-000415-0r for pgsql-bugs@postgresql.org; Fri, 02 Feb 2018 01:49:52 +0000 Received: by mail-pg0-x241.google.com with SMTP id x25so696852pge.3 for ; Thu, 01 Feb 2018 17:49:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8ULSQSiqlM0UkVc/IDQM15V6pX0vSj2jPbUst5UD+hY=; b=HM45uiTA+dZQrs41C96I+pTyk8rRyiEvfjrS2rtyKneGrT9F3cZh9N1x/wTvWCDm9i lY/uzdKdnpVJgMTjfJLcYBNeEMl15cfUjXulnK0H0EfYbNTBN+7jbeuzufoTpEF3Psvx 5oAl90JSrB7udIPrT1OxcMdaMp2+w7RigNKd+KkenDcpaF5Sv5Y+aQWChze+gBFOVgGi zsw270RB+OBlq1fVawFBlwm5IpNxpBFShAYufPkYkdwONhThBQcNGvRrfyxD3n9woq5Z Z7cbOiVTRauhFalK6H7/9zcRV1DfwSXJ5foxQgcUT1jsU8Q/tuFVKXYCkG5ixOiu+7iq 864g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8ULSQSiqlM0UkVc/IDQM15V6pX0vSj2jPbUst5UD+hY=; b=i/9U+jdtAfmWfh/zYPOlZY1KQkQTUFsIUG1LLD7A09X3IErY6VhtaKOQ6lCCjKSNpI o7hIT9NwD/pjGWdl8ZRY3t0kNl59j2GMwQzRBFJdrQXAaGCOeK/KOzHm8FpOUpBOrG4Z fCYig3Fszd2Ae3da2TJX26PbPp686O2EJyJL1UscGGVK5cnARESzOzVC4rPKEnqmkWnp x5b305p98pzbEYTTI+upC6eSrJvWe6Gb9F001wzcM1N//hcOC3n+sDYns/zfHU6V2xUh 8iwjEqdLf93Jda2MEx3hjeDST642p2iLoGHjJ/PxFY2RrjHlvI1rW/D8uU+nN79ukkSi 94tg== X-Gm-Message-State: AKwxyte3lY9829dUV9shdO603bMi9UeUD678onnpGyKWKvx40Q9F63GT kR1WVQMSEbtl0xCPQ9HD4NimFw== X-Google-Smtp-Source: AH8x224y02cUKOA2TzvugybmJFG8yAHGXST3vek/gK6avV74861Ks4iT6gKLfpH7fdIwKt4o4DvPAQ== X-Received: by 10.98.10.199 with SMTP id 68mr10926660pfk.202.1517536187696; Thu, 01 Feb 2018 17:49:47 -0800 (PST) Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp. [61.215.137.162]) by smtp.gmail.com with ESMTPSA id v20sm916752pfe.176.2018.02.01.17.49.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2018 17:49:45 -0800 (PST) Date: Fri, 2 Feb 2018 10:49:39 +0900 From: Michael Paquier To: Peter Eisentraut Cc: Tom Lane , steven.winfield@cantabcapital.com, PostgreSQL mailing lists Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value Message-ID: <20180202014939.GA31363@paquier.xyz> 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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="IJpNTDwzlM2Ie8A6" Content-Disposition: inline In-Reply-To: <6a328b03-6912-2d12-2be6-387d4a1613c7@2ndquadrant.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 01, 2018 at 10:24:48AM -0500, Peter Eisentraut wrote: > On 12/30/17 18:26, Michael Paquier wrote: >> A RangeVar is used for the proposed patch 0002. Still does it matter? In >> the scenario proposed here, which is to fix ALTER TABLE ADD COLUMN >> GENERATED, then the sequence gets created and visible only once the >> transaction adding the column has been created. >>=20 >> char identity; /* attidentity setting */ >> + RangeVar *identitySequence; >> CollateClause *collClause; /* untransformed COLLATE spec, if any */ >> It mat be better to tell that this is used to create a sequence in the >> same transaction as the one doing the parsing. >=20 > I would like to get this into next week's minor release as a bug fix. > Other than tweaking some of the comments, is there any more feedback on > this? 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. 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; --b= locks * Session 2: commit; And then session 1 reports that: ERROR: 23505: duplicate key value violates unique constraint "pg_type_typn= ame_nsp_index" DETAIL: Key (typname, typnamespace)=3D(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 We surely want to be smarter with the choice of the sequence name for identity columns. Index names for primary keys are if I recall correctly indexcmds.c and index.c. -- Michael --IJpNTDwzlM2Ie8A6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlpzw7MACgkQnvQgOdby QH3YGQ/9H3RIylt6D05BlP76DGCvJMYKFA7qyRap2ZbT4mcc3ENPqT+2jciI070I kAy6rncm5T06SU5e6I6oRU7E4drQXjkPVo5/hVAUCWQdGptwOzSCfGEY0OrgrD4Z fp3JLnWWkfLaraG3e14fGyMHlxAqjs39IeBjmq/Hw869GBcSAz24s+26yvDyzEBo Pu2AiG0n4BzKEhrAacB7VWi01wKU0ZRRu4Dv1ZEWFavzWkRyMdyBG94AD0RS43jb 0FA1EFslDxSMIbkoxTgTV2rpI+S2XGGzpclGMRJxSHnNW3VBkAZwV/6LKJupUAoE XRLycqJjd9UtfmKWJ8FDpHJm3NJi7qEsmo7Mj7RhAT4qulXdJMcVYh3LesrnF0QT aFx2CbkK7E3NkzMNBwPu9KeIY+BdtqAoa8RCMRvBvJ+pdLU89DbVLm13fRzb0aqt kpCbdp2gev73Irm6DRLW3o+I+IkmzNfRnduCth2s6nTumkeUUrEQnJzA/UirwptL et9EEkHUgNezRbdX5d2TzvZmKPMdetkGOOK99Z4HOIhsz4FFylR/k2pqWnvjjQ89 Mie+pefzkjs/b7N90TMVh1drqN9oLT35PqzxH92Wge1fMR20zU939wgAu97/HK5t E7q3urGl9vKA9CAeez9amSxd0FG+9/90H10E7rwq5S9pshdsrQ4= =DaZE -----END PGP SIGNATURE----- --IJpNTDwzlM2Ie8A6--