From: Tom Lane <tgl@sss.pgh.pa.us>
To: jsturgeon@novetta.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16088: Multiple foreigh keys created on "ALTER TABLE" command
Date: Tue, 29 Oct 2019 11:37:05 -0400
Message-ID: <23525.1572363425@sss.pgh.pa.us> (raw)
In-Reply-To: <16088-d8dbfda0fb069e93@postgresql.org>
References: <16088-d8dbfda0fb069e93@postgresql.org>
PG Bug reporting form <noreply@postgresql.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
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, jsturgeon@novetta.com
Subject: Re: BUG #16088: Multiple foreigh keys created on "ALTER TABLE" command
In-Reply-To: <23525.1572363425@sss.pgh.pa.us>
References: <16088-d8dbfda0fb069e93@postgresql.org> <23525.1572363425@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