Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iCrPF-0001kr-4w for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Sep 2019 20:27:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iCrPD-0000ez-OP for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Sep 2019 20:27:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iCrPD-0000eq-HN for pgsql-bugs@lists.postgresql.org; Tue, 24 Sep 2019 20:27:27 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iCrPA-0003Tq-Q1 for pgsql-bugs@lists.postgresql.org; Tue, 24 Sep 2019 20:27:27 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x8OKRMXa001312; Tue, 24 Sep 2019 16:27:22 -0400 From: Tom Lane To: "Alfred R. Fuller" cc: pgsql-bugs@lists.postgresql.org Subject: Re: Bug with "CHECK" when part of ALTER TABLE ... ADD COLUMN IF NOT EXISTS ... CHECK ... In-reply-to: References: Comments: In-reply-to "Alfred R. Fuller" message dated "Tue, 24 Sep 2019 11:37:39 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1310.1569356842.1@sss.pgh.pa.us> Date: Tue, 24 Sep 2019 16:27:22 -0400 Message-ID: <1311.1569356842@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Alfred R. Fuller" 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.1558909428@sss.pgh.pa.us