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 1kwoWG-0007Ck-EQ for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Jan 2021 15:45:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kwoWE-00081D-Qn for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Jan 2021 15:45:10 +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 1kwoWE-000814-Bf for pgsql-bugs@lists.postgresql.org; Tue, 05 Jan 2021 15:45:10 +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 1kwoW7-0005hf-Qd for pgsql-bugs@lists.postgresql.org; Tue, 05 Jan 2021 15:45:09 +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 105Fj2Do3379437; Tue, 5 Jan 2021 10:45:02 -0500 From: Tom Lane To: dperham@opex.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16805: "ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... PRIMARY KEY" fails if column exists and is the primary In-reply-to: <16805-4e3f8b42fbe7622c@postgresql.org> References: <16805-4e3f8b42fbe7622c@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Tue, 05 Jan 2021 01:23:04 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3379435.1609861502.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 05 Jan 2021 10:45:02 -0500 Message-ID: <3379436.1609861502@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > ALTER TABLE IF EXIST foo ADD COLUMN IF NOT EXISTS id BIGSERIAL PRIMARY K= EY; = > Fails if "id" exists and is already the primary key. Yeah, known problem. This is fixed in v13, but the fix seemed too invasive for a back-patch (see [1] and follow-on fixes). regards, tom lane [1] https://git.postgresql.org/gitweb/?p=3Dpostgresql.git&a=3Dcommitdiff&h= =3D1281a5c90