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

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: Matheus Alcantara <matheusssilv97@gmail.com>, jian he <jian.universality@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-02-24T09:44:21Z
Lists: pgsql-hackers
On 21.01.26 20:26, Matheus Alcantara wrote:
> On 21/01/26 02:10, jian he wrote:
>>> +      Replacing the expression of a virtual generated columns do not 
>>> require a
>>> +      table rewrite, however if the column is part of a 
>>> <literal>CHECK</literal>
>>> +      constraint expression, the constraint will be rebuilt, 
>>> requiring a table
>>> +      scan to ensure that existing rows meet the constraint.
>>>
>>> I think that it sounds better with: "Replacing the expression of a
>>> virtual generated column does not require a table rewrite..."
>>
>> sure. please check the attached.
>>
> 
> Thanks. The patch is in a good shape for me, I don't have any other 
> comments. Perhaps we could move the CF status for "Ready for Committer"?

(As a matter of process, if you, as the reviewer, feel like you have 
reviewed all you could, then it is appropriate for you to change the 
status to "Ready for Committer".)

I have committed this.

I changed the wording in the documentation a bit, mentioning just 
"constraints" in general, since this also applies to the existing 
support for not-null constraints, and it would presumably apply to other 
kinds of constraints as well, if we want to support those.




Commits

  1. Allow ALTER COLUMN SET EXPRESSION on virtual columns with CHECK constraints