Re: BUG #16088: Multiple foreigh keys created on "ALTER TABLE" command

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jsturgeon(at)novetta(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16088: Multiple foreigh keys created on "ALTER TABLE" command
Date: 2019-10-29 15:37:05
Message-ID: 23525.1572363425@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> If you run this command multiple times:

> ALTER TABLE myschema.mytable ADD IF NOT EXISTS mycolumn uuid REFERENCES
> myschema.mytable2(userid);

> It adds the column once, but adds a duplicate FOREIGN KEY each time.

Yeah, this is a well known problem :-(. The IF NOT EXISTS conditionalizes
addition of the column, but not the quasi-independent addition of the
foreign key constraint. There's work afoot to make this behave more
intuitively, but it won't land before v13 at the earliest.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Euler Taveira 2019-10-29 23:56:26 Re: BUG #16086: Cannot connect using psql, however I can connect using pgadmin
Previous Message PG Bug reporting form 2019-10-29 15:26:19 BUG #16088: Multiple foreigh keys created on "ALTER TABLE" command