Re: [WIP] ALTER COLUMN IF EXISTS - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: [WIP] ALTER COLUMN IF EXISTS
Date
Msg-id CAKFQuwbykodeu=XKbBf3entvGgkNM9=WFbh5eP5_NFo71nsYFw@mail.gmail.com
Whole thread Raw
In response to [WIP] ALTER COLUMN IF EXISTS  (Bradley Ayers <bradley.ayers@gmail.com>)
Responses Re: [WIP] ALTER COLUMN IF EXISTS  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [WIP] ALTER COLUMN IF EXISTS  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Thu, Mar 31, 2022 at 4:39 PM Bradley Ayers <bradley.ayers@gmail.com> wrote:

I'm interested in adding more ergonomics to DDL commands, in
particular supporting IF EXISTS for ALTER TABLE … ALTER COLUMN, so
that if a column doesn't exist the command is skipped.

IF EXISTS is already supported in various places (e.g. ALTER TABLE …
ADD COLUMN IF NOT EXISTS, and ALTER TABLE … DROP COLUMN IF EXISTS),
but it's not available for any of the ALTER COLUMN sub commands.

At present the project seems to largely consider the IF EXISTS/IF NOT EXISTS features to have been largely a mistake and while removing it is not going to happen the desire to change or extend it is not strong.

If you want to make a go at this I would suggest not writing any new code at first but instead take inventory of what is already implemented, how it is implemented, what gaps there are, and proposals to fill those gaps.  Write the theory/rules that we follow in our existing (or future) implementation of this idempotence feature.  Then get agreement to implement the proposals from enough important people that a well-written patch would be considered acceptable to commit.
I don't know if any amount of planning and presentation will convince everyone this is a good idea in theory, let alone one that we want to maintain while the author goes off to other projects (this being your first patch that seems like a reasonable assumption).

I can say you have some community support in the endeavor but, and maybe this is biasing me, my (fairly recent) attempt at what I considered bug-fixing in this area was not accepted.  On that note, as part of your research, you should find the previous email threads on this topic (there are quite a few I am sure), and make you own judgements from those.  Aside from it being my opinion I don't have any information at hand that isn't in the email archives.

David J.

pgsql-hackers by date:

Previous
From: Michail Nikolaev
Date:
Subject: Re: [PATCH] Full support for index LP_DEAD hint bits on standby
Next
From: Robert Haas
Date:
Subject: Re: unlogged sequences