support ALTER TABLE DROP EXPRESSION for virtual generated column

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: support ALTER TABLE DROP EXPRESSION for virtual generated column
Date: 2025-03-27 01:54:52
Message-ID: CACJufxEE3edZ3UDSLHa_6Xmj8pbsHEcnJCjppAb_gqwetGdjxQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.

the attached patch is to implement $subject.
the generation expression will be dropped.
the column value previous was NULL will be materialized
based on generation expression.

It seems fairly straightforward:
drop the generation expression in ATExecDropExpression,
and instruct phase 3 to compute the generation expression
and do the table rewrite.

the doc changes:

<para>
- This form turns a stored generated column into a normal base column.
- Existing data in the columns is retained, but future changes will no
- longer apply the generation expression.
- </para>
-
- <para>
- This form is currently only supported for stored generated columns (not
- virtual ones).
+ This form turns a generated column into a normal base column.
+ For stored generated column, existing data in the columns is retained;
+ For virtual generated column, it will compute the generation
expression and
+ store the value in the columns. For inheritance hierarchy or
partition hierarchy,
+ the virtual generation expression is computed based on the
child's own generation expression.
+ The future changes will no longer apply the generation expression.
</para>

Attachment Content-Type Size
v1-0001-support-ALTER-TABLE-DROP-EXPRESSION-for-virtual-g.patch text/x-patch 14.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message wenhui qiu 2025-03-27 02:03:22 Re: POC: make mxidoff 64 bits
Previous Message Michael Paquier 2025-03-27 01:53:57 Re: making EXPLAIN extensible