pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #15981: Alter table add column if not exists with constraint fails on constraint
2+ messages / 2 participants
[nested] [flat]
* BUG #15981: Alter table add column if not exists with constraint fails on constraint
@ 2019-08-27 15:07 PG Bug reporting form <noreply@postgresql.org>
2019-08-27 15:33 ` Re: BUG #15981: Alter table add column if not exists with constraint fails on constraint Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2019-08-27 15:07 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: e.oneal89@gmail.com
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.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #15981: Alter table add column if not exists with constraint fails on constraint
2019-08-27 15:07 BUG #15981: Alter table add column if not exists with constraint fails on constraint PG Bug reporting form <noreply@postgresql.org>
@ 2019-08-27 15:33 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2019-08-27 15:33 UTC (permalink / raw)
To: e.oneal89@gmail.com; +Cc: pgsql-bugs@lists.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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2019-08-27 15:33 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 15:07 BUG #15981: Alter table add column if not exists with constraint fails on constraint PG Bug reporting form <noreply@postgresql.org>
2019-08-27 15:33 ` Tom Lane <tgl@sss.pgh.pa.us>
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