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 1fwQoq-0001OF-Oq for pgsql-bugs@arkaria.postgresql.org; Sun, 02 Sep 2018 11:45:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fwQom-0001Hb-Q5 for pgsql-bugs@arkaria.postgresql.org; Sun, 02 Sep 2018 11:45:24 +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 1fwQom-0001HG-GV for pgsql-bugs@lists.postgresql.org; Sun, 02 Sep 2018 11:45:24 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fwQof-00059C-7D for pgsql-bugs@lists.postgresql.org; Sun, 02 Sep 2018 11:45:23 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 022945F79C; Sun, 2 Sep 2018 07:45:15 -0400 (EDT) Date: Sun, 2 Sep 2018 07:45:15 -0400 From: Stephen Frost To: Tom Lane Cc: postgresql@noetika.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15361: Add column if not exists create duplicate constraint Message-ID: <20180902114515.GB4184@tamriel.snowman.net> References: <153582193030.31898.16505654463153733444@wrigleys.postgresql.org> <8965.1535826302@sss.pgh.pa.us> <9734.1535827326@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="MfFXiAuoTsnnDAfZ" Content-Disposition: inline In-Reply-To: <9734.1535827326@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --MfFXiAuoTsnnDAfZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Tom Lane (tgl@sss.pgh.pa.us) wrote: > 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. >=20 > 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.) >=20 > The thing I was half-remembering was probably this bug report about > the unique-constraint aspect of the same problem: >=20 > https://www.postgresql.org/message-id/flat/152509815280.19803.16118194452= 213577808%40wrigleys.postgresql.org >=20 > 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. For my 2c, at least, I continue to be of the opinion (as it seems the OP is also..) that IF NOT EXISTS means "ONLY DO THIS IF THE OBJECT REFERENCED DOESN'T EXIST". There certainly seemed to be a lack of dissenting opinion by the end of that thread, so maybe it's time to actually make that change. I still consider the current behavior to be a bug, but I could see an argument for not back-patching it out of concern about breaking scripts in a back-patch and because the code looks like it'd need to be whacked around some. Thanks! Stephen --MfFXiAuoTsnnDAfZ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJbi81LAAoJEO1sijiDR2RVfswP/2QiMVUCu6TmbXF9ztyGL7Gg xDl6BkceQiByCvLMEtFdlBriuwhU+eOQUejafs1lL5uMc1IYckn8HW7Nin+W9LGR 8yJoS+Dj2hPeV2uj9nJMYYZTgPaW+KpMkUOcsP+Gwn5PbK/GU/I8ikT3ICdmL9m0 rW5X2N1wunqt77VkfQ0Kb7svHDewibBZiNFLdXhxa/wOTpq9UvPcl6UmGXxtr0vN WUo8UEx1WYq5J5t5dAwOFb3PVGFOvj2SrJNzngM81+jsVCf5IvmWGeT3J3o1JcUK TD6S9bN3CA5V+bw1hU4Bq4IEs+JkOMg9X4ODobkRxN+xhuvgXCPxrPtWy6v21gI8 1D9SisJr7HQfjaOzwhnl15/mEI4C7d5Wb9eytZGdYXS8/cxhsJyM8RNFw4COXVKb vUDQrcCch+LgAr9mf4zeb7rvLQe2TRI5PBG6P5V59nFjzvZ/fWFys/BW6bTBW/kV 1NvWVNdsKQseIgstt1Es5zFCSsedpP8YIwOapr3ZrxRDGoZ7QLsYgd/HrCRsAdLn JidQLY4KqonOSzrlfOwh8Vg7sDmIbtGz3My9SDcXqej/mO/ukDlQiuw784MWaAhJ 2XYSGXutkh9d4d/MvFvNjll4N8aTVeUb4eLVQExt768q6BsnqwXOxAvYjieBi80q PSMCC/HOfsjBxQj5COx/ =gGnK -----END PGP SIGNATURE----- --MfFXiAuoTsnnDAfZ--