Re: BUG #15710: ADD COLUMN IF NOT EXISTS adds constraint anyways

From: Christoph Berg <myon(at)debian(dot)org>
To: thomas(at)palan(dot)at, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15710: ADD COLUMN IF NOT EXISTS adds constraint anyways
Date: 2019-03-22 08:36:14
Message-ID: 20190322083614.GA32388@msg.df7cb.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Re: PG Bug reporting form 2019-03-21 <15710-f52bad04543be4cb(at)postgresql(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Dean Rasheed 2019-03-24 11:19:52 Re: BUG #15708: RLS 'using' running as wrong user when called from a view
Previous Message Amit Langote 2019-03-22 05:49:42 Re: BUG #15668: Server crash in transformPartitionRangeBounds