Re: support ALTER TABLE DROP EXPRESSION for virtual generated column

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: support ALTER TABLE DROP EXPRESSION for virtual generated column
Date: 2025-03-27 03:44:37
Message-ID: CAKFQuwZt41PbKGwc4rFeZsrUZ0jiunrZ7macvQyhm6QLNwBrPQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wednesday, March 26, 2025, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> jian he <jian(dot)universality(at)gmail(dot)com> writes:
> > the attached patch is to implement $subject.
>
> Why would this be a good idea? I don't see any principled fallback
> definition of the column. (No, "NULL" is not that.) Certainly we
> should support ALTER TABLE DROP COLUMN, but removing the expression
> and not providing a substitute seems semantically nonsensical.
>

I don’t follow how NULL got involved in this discussion. The proposal is
basically: turn the virtual expression into an equivalent stored
expression, then drop the expression.

I suppose it would make sense to first add an alter table command to allow
the user to do a virtual/stored mode swap manually before adding this,
which then just becomes a convenient way to specify swap-and-drop as a
single command.

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message cca5507 2025-03-27 03:47:32 Re: Historic snapshot doesn't track txns committed in BUILDING_SNAPSHOT state
Previous Message Nathan Bossart 2025-03-27 03:38:42 Re: [PATCH] SVE popcount support