public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Stephen Carboni <[email protected]>
Cc: [email protected]
Subject: Re: Why is there no ADD CONSTRAINT IF NOT EXISTS ?
Date: Wed, 21 Apr 2021 10:08:00 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAN-rLW_L0s-nt5AC5A=RLtCjeB-aaZRd-oRfkKf0OeYXCNzHng@mail.gmail.com>
References: <CAN-rLW_L0s-nt5AC5A=RLtCjeB-aaZRd-oRfkKf0OeYXCNzHng@mail.gmail.com>

Stephen Carboni <[email protected]> writes:
> I can drop a constraint if it exists, but cannot simply add one if it does
> not exist. Is there something especially difficult about supporting this?

Probably some combination of (1) nobody got around to it yet and
(2) it's not entirely clear what the semantics ought to be.
Should we match on name, or contents of the constraint, and how
picky would a content match be?

There's a general problem with CREATE IF NOT EXISTS that you don't
really have any guarantee afterwards as to what are the details
of the object's definition.  Personally I prefer CREATE OR REPLACE
semantics, where you do know what the object looks like afterwards.
However, C.O.R. doesn't work that well unless there's a very clear
unique identity (e.g. name) for the object.  Since constraints are
often made without specifying a name, it's hard to be sure what
you're supposed to replace.  I'm not sure whether C.I.N.E. would
have as bad of a problem with that, but it seems possible.

			regards, tom lane





view thread (2+ messages)

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Why is there no ADD CONSTRAINT IF NOT EXISTS ?
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox