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