Re: Fix SET EXPRESSION for virtual columns with whole-row dependencies - Mailing list pgsql-hackers

From Chao Li
Subject Re: Fix SET EXPRESSION for virtual columns with whole-row dependencies
Date
Msg-id 5B739323-C897-4B1A-9BFC-656E5CB4AD58@gmail.com
Whole thread
In response to Re: Fix SET EXPRESSION for virtual columns with whole-row dependencies  (jian he <jian.universality@gmail.com>)
List pgsql-hackers

> On Jun 9, 2026, at 15:23, jian he <jian.universality@gmail.com> wrote:
>
> On Tue, Jun 9, 2026 at 2:23 PM Chao Li <li.evan.chao@gmail.com> wrote:
>>
>> Hi,
>>
>> While testing “[f80bedd52] Allow ALTER COLUMN SET EXPRESSION on virtual columns”, I found that the feature missed
handlingwhole-row check constraints. 
>>
>> Here is a repro:
>> ```
>> evantest=# create table t(
>> evantest(#   a int,
>> evantest(#   b int generated always as (a*2) virtual,
>> evantest(#   constraint row_c check (t is not null)
>> evantest(# );
>> CREATE TABLE
>> evantest=# insert into t(a) values(1);
>> INSERT 0 1
>> evantest=# alter table t alter b set expression as (nullif(a, 1));
>> ALTER TABLE
>> evantest=# select * from t;
>> a | b
>> ---+---
>> 1 |
>> (1 row)
>> ```
>>
>> The ALTER TABLE should fail, because it makes b become NULL, which breaks the constraint row_c.
>>
>
> Hi.
>
> In case you are wondering whole-row objects:
> ALTER TABLE DROP COLUMN and ALTER COLUMN SET DATA TYPE are covered by
> https://commitfest.postgresql.org/patch/5988 and
> https://commitfest.postgresql.org/patch/6055.
>
> Meanwhile, ALTER TABLE SET EXPRESSION is being handled over in
> https://commitfest.postgresql.org/patch/6755

Thanks for pointing out that. I will review 6755.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: Re: Fix SET EXPRESSION for virtual columns with whole-row dependencies
Next
From: Benoit Lobréau
Date:
Subject: Re: Logging parallel worker draught