From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Isaac Morland <isaac(dot)morland(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 15:37:22 |
Message-ID: | CA+TgmoZHctwqi=zLZNpRrD8ieTfT7FQicx0iqCTdU1=e-SH8Ug@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Nov 5, 2021 at 10:40 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> In this framework, RENAME IF EXISTS is in sort of a weird place.
> You'd know that afterwards there is no longer any column with the
> source name. But you are not entitled to draw any conclusions
> about whether a column exists with the target name, nor what its
> properties are. So that makes me feel like the semantics are more
> on the poorly-defined than well-defined side of the fence.
I have mixed feelings about this proposal. As you may recall, I was a
big fan of CREATE IF NOT EXISTS because it's a super-useful thing in
DDL upgrade scripts. You have an application and every time you deploy
it you CREATE IF NOT EXISTS all the tables that are supposed to be
there. As long as the application is careful not to modify any table
definitions, and nothing else is changing the database, this works
great. You can add functionality by adding new tables, so the schema
can be upgraded before the app. Life is good.
Making renaming work in the same kind of context is harder. You're
definitely going to have to upgrade the application and the schema in
lock step, unless the application is smart enough to work with the
column having either name. You're also going to end up with some
trouble if you ever reuse a column name, because then the next time
you run the script it might rename the successor of the original
column by that name rather than the column you intended to rename. So
it seems more finnicky to use.
But I'm also not sure that it's useless. People don't usually ask for
a feature unless they have a use in mind for it. Also, adding an
option to skip failures when the object is missing is a popular kind
of thing. The backend is full of functions that have a missingOK or
noError flag, for example. Maybe the fact that I don't quite see how
to use this effectively is just lack of imagination on my part....
--
Robert Haas
EDB: http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2021-11-05 15:47:48 | Re: [PATCH] rename column if exists |
Previous Message | Jan Wieck | 2021-11-05 15:36:31 | Re: should we enable log_checkpoints out of the box? |