Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVIXp-0003Af-PU for pgsql-general@arkaria.postgresql.org; Tue, 28 Sep 2021 19:13:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mVIXn-0005F6-GH for pgsql-general@arkaria.postgresql.org; Tue, 28 Sep 2021 19:13:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVIXn-0005Ey-6u for pgsql-general@lists.postgresql.org; Tue, 28 Sep 2021 19:13:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVIXg-0005LD-TE for pgsql-general@lists.postgresql.org; Tue, 28 Sep 2021 19:13:34 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 18SJDRxo2870867; Tue, 28 Sep 2021 15:13:27 -0400 From: Tom Lane To: Jeff Hoffmann cc: pgsql-general@lists.postgresql.org Subject: Re: Problem with identity column & related sequences In-reply-to: References: Comments: In-reply-to Jeff Hoffmann message dated "Tue, 28 Sep 2021 13:38:47 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2870865.1632856407.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 28 Sep 2021 15:13:27 -0400 Message-ID: <2870866.1632856407@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jeff Hoffmann writes: > I am using postgresql-12.8. I am using I am making use of an identity > column for part of a scripts to process some updated data. Because of > the way the script is called I don't necessarily know if this column > is going to exist in the table I am working on so I have a step that > will conditionally create the column if it doesn't already exist, i.e. > alter table mytable add column if not exists unique_id integer > generated always as identity; You're right, this sort of thing does not work very well in v12 and before. We fixed it in v13, but the changes seemed far too invasive to risk a back-patch [1]. regards, tom lane [1] https://git.postgresql.org/gitweb/?p=3Dpostgresql.git&a=3Dcommitdiff&h= =3D1281a5c90