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

From Tom Lane
Subject Re: BUG #15670: alter table .. add column if not exists ... references ...; adds a FK constraint on each execution
Date
Msg-id 18788.1551798880@sss.pgh.pa.us
Whole thread Raw
In response to BUG #15670: alter table .. add column if not exists ... references ...; adds a FK constraint on each execution  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.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


pgsql-bugs by date:

Previous
From: Amit Langote
Date:
Subject: Re: BUG #15668: Server crash in transformPartitionRangeBounds
Next
From: Amit Langote
Date:
Subject: Re: BUG #15670: alter table .. add column if not exists ...references ...; adds a FK constraint on each execution