Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fwAqb-0005dp-Kv for pgsql-bugs@arkaria.postgresql.org; Sat, 01 Sep 2018 18:42:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fwAqZ-0006Mz-Ot for pgsql-bugs@arkaria.postgresql.org; Sat, 01 Sep 2018 18:42:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fwAqZ-0006Ms-Fh for pgsql-bugs@lists.postgresql.org; Sat, 01 Sep 2018 18:42:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fwAqW-0007AG-Iu for pgsql-bugs@lists.postgresql.org; Sat, 01 Sep 2018 18:42:10 +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 w81Ig6wX009735; Sat, 1 Sep 2018 14:42:06 -0400 From: Tom Lane To: postgresql@noetika.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15361: Add column if not exists create duplicate constraint In-reply-to: <8965.1535826302@sss.pgh.pa.us> References: <153582193030.31898.16505654463153733444@wrigleys.postgresql.org> <8965.1535826302@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 01 Sep 2018 14:25:02 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9733.1535827326.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 01 Sep 2018 14:42:06 -0400 Message-ID: <9734.1535827326@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > I believe this exact issue was debated when ADD COLUMN IF NOT EXISTS > was added, and the camp that wanted it thought this behavior was fine. After a bit of digging in the archives, I failed to find any evidence that the point was considered when the ADD COLUMN IF NOT EXISTS patch went in, though there have certainly been related threads in the dim past, which basically led to the conclusion that you don't get to have much certainty about what state IF NOT EXISTS leaves behind, and those who think it's a good feature think that's OK. (I am not among them.) The thing I was half-remembering was probably this bug report about the unique-constraint aspect of the same problem: https://www.postgresql.org/message-id/flat/152509815280.19803.161181944522= 13577808%40wrigleys.postgresql.org wherein it was argued that if the IF NOT EXISTS fires, it should prevent all side-effects of the ADD COLUMN clause it's attached to, whether or not any of the subsidiary objects exist (in some form) already. If you buy that theory then there's a sketch for a fix there. Nobody's done anything about it AFAIK. regards, tom lane