BUG #15981: Alter table add column if not exists with constraint fails on constraint - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15981: Alter table add column if not exists with constraint fails on constraint
Date
Msg-id 15981-1c21384db6d3e7f1@postgresql.org
Whole thread Raw
Responses Re: BUG #15981: Alter table add column if not exists with constraint fails on constraint  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15981
Logged by:          Erika ONeal
Email address:      e.oneal89@gmail.com
PostgreSQL version: 11.5
Operating system:   Debian
Description:

SQL to reproduce:

`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`

Expected Outcome: If the column already exists, it should not attempt to
index it with the column constraint. Or if that is the correct behavior, the
documentation does not reflect that.


pgsql-bugs by date:

Previous
From: Matt Wise
Date:
Subject: Re: BUG #15959: 'DROP EXTENSION pglogical' while an unused logicalreplication slot exists causes slot corruption
Next
From: Tom Lane
Date:
Subject: Re: BUG #15981: Alter table add column if not exists with constraint fails on constraint