Re: [PATCH] rename column if exists

From: Isaac Morland <isaac(dot)morland(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, David Oksman <oksman(dot)dav(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] rename column if exists
Date: 2021-11-05 12:03:58
Message-ID: CAMsGm5d2mY_aXkhreY9Vd4zeLJdZEquQnUtCkYvSmy3GBmWTqw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 5 Nov 2021 at 05:21, Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:

> > Same reasoning as for all the other if exists we have, idempotence.
> Being able to run the command on an object that is already in the desired
> state without provoking an error.
>
> If the object is known to be in the desired state, there is no need to use
> IF
> EXISTS. Personally I think IF EXISTS commands are useful when they
> provide a
> transition to a known end state, but in this case it's an unknown end
> state.
>

The whole point of IF EXISTS, not to mention IF NOT EXISTS and OR REPLACE,
is that the same script can run without error on a variety of existing
schemas. They aren't (primarily) for typing directly at the psql prompt. At
the time the script is written, the state of the object when the script is
run is unknown.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2021-11-05 12:06:50 Re: pgsql: Fix WAL replay in presence of an incomplete record
Previous Message Hayk Manukyan 2021-11-05 11:17:49 Re: Feature request for adoptive indexes