Re: Bug with "CHECK" when part of ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... CHECK ...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Alfred R(dot) Fuller" <alfred(dot)fuller(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Bug with "CHECK" when part of ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... CHECK ...
Date: 2019-09-24 20:27:22
Message-ID: 1311.1569356842@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Alfred R. Fuller" <alfred(dot)fuller(at)gmail(dot)com> writes:
> Expected behavior:
> If the column exists nothing is altered.
> Actual behavior:
> The check is always added regardless if the column exists or not.

Yeah, this is yet another variant of the theme that ADD COLUMN IF EXISTS
only conditionalizes the creation of the column proper, and not other
subsidiary subcommands such as adding indexes or constraints. I've been
poking at a fix [1], and hopefully we'll get it dealt with in v13, but
for sure it'll be a bigger change than we'd risk back-patching.

regards, tom lane

[1] https://www.postgresql.org/message-id/flat/10365(dot)1558909428(at)sss(dot)pgh(dot)pa(dot)us

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Fabrízio de Royes Mello 2019-09-24 20:31:41 Re: Bug with "CHECK" when part of ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... CHECK ...
Previous Message Fabrízio de Royes Mello 2019-09-24 20:27:19 Re: Bug with "CHECK" when part of ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... CHECK ...