Re: support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint

From: "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com>
To: "jian he" <jian(dot)universality(at)gmail(dot)com>, "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com>
Cc: "PostgreSQL Hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint
Date: 2026-01-15 15:29:28
Message-ID: DFP9Q7B4R7TC.2YTXG1MRFDRFT@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu Jan 15, 2026 at 1:31 AM -03, jian he wrote:
> On Thu, Jan 15, 2026 at 5:02 AM Matheus Alcantara
> <matheusssilv97(at)gmail(dot)com> wrote:
>>
>> Please see the attached diff for reference.
>
> hi.
> Your patch made the test more simple.
> so i added a ``\d gtest20``
>
> I aslo polished the commit message.
>
Thanks for the new version. The commit message seems better. Just a few
comments:

+ /*
+ * Find everything that depends on the column (constraints, indexes, etc),
+ * and record enough information to let us recreate the objects after
+ * rewrite.
+ */
+ RememberAllDependentForRebuilding(tab, AT_SetExpression, rel, attnum, colName);
+
Perhaps this comments should be updated since we are now collecting
these dependencies for virtual generated columns too that it not require
a table rewrite.

---

I think that it would be good to update the SET EXPRESSION AS
documentation on doc/src/sgml/ref/alter_table.sgml to mention that for
virtual columns the table is not rewritten but a full table scan may
still be needed if the column has check constraints.

--
Matheus Alcantara
EDB: https://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2026-01-15 15:38:43 io_uring: Fix danger of completion getting reused before being read
Previous Message Tom Lane 2026-01-15 15:26:51 Re: remove the unneeded header file math.h in binaryheap.c