pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: e.oneal89@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15981: Alter table add column if not exists with constraint fails on constraint
Date: Tue, 27 Aug 2019 11:33:21 -0400
Message-ID: <13277.1566920001@sss.pgh.pa.us> (raw)
In-Reply-To: <15981-1c21384db6d3e7f1@postgresql.org>
References: <15981-1c21384db6d3e7f1@postgresql.org>

PG Bug reporting form <noreply@postgresql.org> writes:
> CREATE TABLE test(id uuid PRIMARY KEY);
> ALTER TABLE test ADD IF NOT EXISTS id uuid PRIMARY KEY;
> Output: `NOTICE:  column "id" of relation "test" already exists, skipping
> ERROR:  multiple primary keys for table "test" are not allowed`

Yeah, this is a well-known issue: the IF NOT EXISTS only conditionalizes
creation of the column, but it's reasonable to expect that it should
conditionalize creation of the index as well.  There's work afoot to
improve this [1], but it's not moving very fast; at the earliest you
might see it fixed in v13.

			regards, tom lane

[1] https://www.postgresql.org/message-id/flat/10365.1558909428%40sss.pgh.pa.us





view thread (2+ messages)

Message-ID: <13277.1566920001@sss.pgh.pa.us>
Permalink:  ../13277.1566920001@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/13277.1566920001@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, e.oneal89@gmail.com
  Subject: Re: BUG #15981: Alter table add column if not exists with constraint fails on constraint
  In-Reply-To: <13277.1566920001@sss.pgh.pa.us>
  References: <15981-1c21384db6d3e7f1@postgresql.org> <13277.1566920001@sss.pgh.pa.us>

* 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