From: Stephen Frost <sfrost@snowman.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: postgresql@noetika.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15361: Add column if not exists create duplicate constraint
Date: Sun, 2 Sep 2018 07:45:15 -0400
Message-ID: <20180902114515.GB4184@tamriel.snowman.net> (raw)
In-Reply-To: <9734.1535827326@sss.pgh.pa.us>
References: <153582193030.31898.16505654463153733444@wrigleys.postgresql.org>
<8965.1535826302@sss.pgh.pa.us>
<9734.1535827326@sss.pgh.pa.us>
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.
>
> 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.16118194452213577808%40wrigleys.postgr...
>
> 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
Attachments:
signature.asc (application/pgp-signature, 818B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: sfrost@snowman.net, tgl@sss.pgh.pa.us, postgresql@noetika.com
Subject: Re: BUG #15361: Add column if not exists create duplicate constraint
In-Reply-To: <20180902114515.GB4184@tamriel.snowman.net>
References: <153582193030.31898.16505654463153733444@wrigleys.postgresql.org> <8965.1535826302@sss.pgh.pa.us> <9734.1535827326@sss.pgh.pa.us> <20180902114515.GB4184@tamriel.snowman.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox