Re: BUG #15670: alter table .. add column if not exists ... references ...; adds a FK constraint on each execution

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: michael(at)mibi(dot)io
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15670: alter table .. add column if not exists ... references ...; adds a FK constraint on each execution
Date: 2019-03-05 15:14:40
Message-ID: 18788.1551798880@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:
> I don't know if this is the expected behavior but when I execute this
> script:
> alter table test2 add column if not exists test1_fk integer not null
> references test1(id);
> alter table test2 add column if not exists test1_fk integer not null
> references test1(id);
> alter table test2 add column if not exists test1_fk integer not null
> references test1(id);
> I end up with 3 FK constrains:

Yeah, this is the same problem previously reported at bug #15180,

https://www.postgresql.org/message-id/flat/152509815280.19803.16118194452213577808%40wrigleys.postgresql.org

We had a sketch for a fix but discussion seems to have trailed off :-(

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Langote 2019-03-05 15:16:10 Re: BUG #15670: alter table .. add column if not exists ... references ...; adds a FK constraint on each execution
Previous Message Amit Langote 2019-03-05 14:04:17 Re: BUG #15668: Server crash in transformPartitionRangeBounds