Re: [PATCH] Rebuild CHECK constraints after generated column SET EXPRESSION

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>, Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: [PATCH] Rebuild CHECK constraints after generated column SET EXPRESSION
Date: 2026-06-10 09:15:38
Message-ID: 4B8C04AD-B4F1-43E3-8BC3-7A8800F3498B@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Jun 2, 2026, at 08:41, jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> On Fri, May 29, 2026 at 6:58 AM Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)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 objects to rebuild.
* My implementation in [1] reuses RememberAllDependentForRebuilding(), which reads pg_depend, because whole-row dependencies have 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 scans pg_index directly for the partial-index case where pg_depend does not record the whole-row Var dependency. It is also smaller: 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/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-06-10 09:21:40 Re: repack: clarify final phase of concurrent mode in file header comment
Previous Message Chao Li 2026-06-10 09:12:58 Re: Fix SET EXPRESSION for virtual columns with whole-row dependencies