Re: BUG #15710: ADD COLUMN IF NOT EXISTS adds constraint anyways - Mailing list pgsql-bugs

From Christoph Berg
Subject Re: BUG #15710: ADD COLUMN IF NOT EXISTS adds constraint anyways
Date
Msg-id 20190322083614.GA32388@msg.df7cb.de
Whole thread Raw
In response to BUG #15710: ADD COLUMN IF NOT EXISTS adds constraint anyways  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
Re: PG Bug reporting form 2019-03-21 <15710-f52bad04543be4cb@postgresql.org>
> CREATE TABLE test (id SERIAL PRIMARY KEY);
> ALTER TABLE test ADD COLUMN IF NOT EXISTS new_column integer UNIQUE;

As a workaround, you can name the constraint:

ALTER TABLE test ADD COLUMN IF NOT EXISTS new_column integer CONSTRAINT id_unique UNIQUE;

Then it won't get added multiple times. (It will still be executed
once, though.)

Christoph


pgsql-bugs by date:

Previous
From: Amit Langote
Date:
Subject: Re: BUG #15668: Server crash in transformPartitionRangeBounds
Next
From: Dean Rasheed
Date:
Subject: Re: BUG #15708: RLS 'using' running as wrong user when called from a view