Re: [PATCH] rename column if exists

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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:58:40
Message-ID: CAKFQuwYx-Ga20Ci8Uq3kA6iY=WNQt3iqJoqZqGM=0m8=+y2zog@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 5, 2021 at 8:37 AM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

>
> 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.
>

This I understand fully, and am fine with leaving it to the user to
handle. They can choose whether rewriting the table (column add with
non-null values) in order to have an easier application migration is better
or worse than doing a rename and just ensuring that the old name is fully
retired (which seems likely).

It can be used profitably and that is good enough for me given that we've
already set a precedent of having IF EXISTS conditionals. That people need
to understand exactly what the command will do, and test their scripts when
using it, is a reasonable expectation. The possibility that some may not
and might have issues shouldn't prevent us from providing a useful feature
to others who will use it appropriately and with care.

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-11-05 16:48:16 Re: WIP: expression evaluation improvements
Previous Message Robert Haas 2021-11-05 15:50:01 Re: refactoring basebackup.c