Re: support ALTER TABLE DROP EXPRESSION for virtual generated column - Mailing list pgsql-hackers

From jian he
Subject Re: support ALTER TABLE DROP EXPRESSION for virtual generated column
Date
Msg-id CACJufxEPiyZXXeGZF=8o10r8_Cj-CfLVsJfHkfe2uxUdw1GnkQ@mail.gmail.com
Whole thread Raw
In response to Re: support ALTER TABLE DROP EXPRESSION for virtual generated column  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-hackers
On Thu, Mar 27, 2025 at 11:44 AM David G. Johnston
<david.g.johnston@gmail.com> wrote:
>
> On Wednesday, March 26, 2025, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>
>> jian he <jian.universality@gmail.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
anequivalent stored expression, then drop the expression. 
>
This discussion [0] wants to change stored to virtual.

drop the virtual generation, not materialize, column value will be NULL,
but that will not work because commit [1]

So we are either saying that
virtual generation expression cannot be dropped, you can only
substitute another expression
or drop the expression, based on the dropped expression materializing
that column value.

[0]: https://postgr.es/m/CAFCRh-8grTkEy%2B73q79iXB%2Bq%2BsD%3DQkbz-vNAN1KJCF6PRLa%3Dzg%40mail.gmail.com
[1]: https://git.postgresql.org/cgit/postgresql.git/commit/?id=cdc168ad4b22ea4183f966688b245cabb5935d1f



pgsql-hackers by date:

Previous
From: Krasiyan Andreev
Date:
Subject: Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options
Next
From: Sutou Kouhei
Date:
Subject: Re: Make COPY format extendable: Extract COPY TO format implementations