Re: Fix bug of CHECK constraint enforceability recursion - Mailing list pgsql-hackers

From Chao Li
Subject Re: Fix bug of CHECK constraint enforceability recursion
Date
Msg-id E6956B70-35FF-474D-9F53-FC6E1BD8D9C0@gmail.com
Whole thread
In response to Re: Fix bug of CHECK constraint enforceability recursion  (jian he <jian.universality@gmail.com>)
Responses Re: Fix bug of CHECK constraint enforceability recursion
List pgsql-hackers

> On Jun 3, 2026, at 14:58, jian he <jian.universality@gmail.com> wrote:
>
> On Tue, Jun 2, 2026 at 2:40 PM Chao Li <li.evan.chao@gmail.com> wrote:
>>
>> Oops! I just found that I forgot to commit a tiny comment tuning in 0001. So posting v6.
>>
> Hi.
>
> One partition cannot have two direct parent tables. see
> ATExecAttachPartition comment:
> /* A partition can only have one parent */
>
> Also
> CREATE TABLE ... PARTITION OF automatically copies the parent
> constraint definition, and
> ALTER TABLE ... ATTACH PARTITION already rejects cases where the
> parent is enforced but the child is not.
>
> Therefore, I think calling ATCheckCheckConstrHasEnforcedParent once is
> enough for partition inheritance.

This is a good point. I addressed it in v6.

>
> Also please check the attached minor refactoring.
>

I accepted the refactoring with a small tuning. When we pull up changing_conids = list_make1_oid(currcon->oid); to
beforethe for loop, we also need to check if (!cmdcon->is_enforced). I also updated the comment accordingly. 

>
> --
> jian
> https://www.enterprisedb.com/
> <checkconstr_inheritance_issue.nocfbot>

Also, thanks for attaching the diff, which made me easy to view your refactoring by applying the diff to my patch
branch.

PFA v6: 0002 and 0003 unchanged. 0001 addressed the two comments from Jian.

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





Attachment

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Use TEXT_DUMP_HEADER macro instead of hard-coded string in pg_backup_archiver.c
Next
From: Chao Li
Date:
Subject: Re: Fix regression in vacuumdb --analyze-in-stages for partitioned tables