Re: [PATCH] Rebuild CHECK constraints after generated column SET EXPRESSION - Mailing list pgsql-hackers

From Chao Li
Subject Re: [PATCH] Rebuild CHECK constraints after generated column SET EXPRESSION
Date
Msg-id 4B8C04AD-B4F1-43E3-8BC3-7A8800F3498B@gmail.com
Whole thread
In response to Re: [PATCH] Rebuild CHECK constraints after generated column SET EXPRESSION  (jian he <jian.universality@gmail.com>)
List pgsql-hackers

> On Jun 2, 2026, at 08:41, jian he <jian.universality@gmail.com> wrote:
>
> On Fri, May 29, 2026 at 6:58 AM Zsolt Parragi <zsolt.parragi@percona.com> wrote:
>>
>> Looks good, I have one nitpick question:
>>
>> +                       if (isnull)
>> +                               elog(WARNING, "null conbin for relation \"%s\"",
>> +                                        RelationGetRelationName(rel));
>>
>> Shouldn't this be an error instead? Most existing checks treat it as
>> an error, and that seems better to me as this shouldn't happen
>> normally?
>>
> OK.
>
> I changed it to:
>> +                       if (isnull)
>> +                               elog(ERROR, "null conbin for relation \"%s\"",
>> +                                        RelationGetRelationName(rel));
>
> I also slightly rephrased the commit message.
>
>
>
> --
> jian
> https://www.enterprisedb.com/

Sorry for not noticing this thread earlier. I also found the same problem while testing the feature and posted a patch
in[1]. Thanks to Jian for pointing out this thread. 

After reading v6 from this thread, I think my implementation is slightly different:

* v6 adds a new helper, RememberWholeRowDependentForRebuilding(), which reads pg_constraint and pg_index to find
objectsto rebuild. 
* My implementation in [1] reuses RememberAllDependentForRebuilding(), which reads pg_depend, because whole-row
dependencieshave refobjsubid = 0. My v1 missed the partial-index case, so I added a new helper in v2 to read pg_index. 

The main difference is that my patch reuses the existing dependency-based rebuild machinery where possible, and only
scanspg_index directly for the partial-index case where pg_depend does not record the whole-row Var dependency. It is
alsosmaller: this thread’s v6 adds 185 lines to tablecmds.c, while my v2 adds 123 lines. 

Would you mind taking a look at my implementation in [1]?

BTW, I have also added this problem to the open items list, as I think it should be fixed before releasing v19.

[1] https://www.postgresql.org/message-id/71242FEA-15A3-4073-9FA1-561CA744ACBD%40gmail.com

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





pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: Fix SET EXPRESSION for virtual columns with whole-row dependencies
Next
From: Chao Li
Date:
Subject: Re: repack: clarify final phase of concurrent mode in file header comment