| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | jian he <jian(dot)universality(at)gmail(dot)com> |
| Cc: | Álvaro Herrera <alvherre(at)kurilemu(dot)de>, "L(dot) pgsql-hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net> |
| Subject: | Re: Fix bug of CHECK constraint enforceability recursion |
| Date: | 2026-06-03 08:17:24 |
| Message-ID: | E6956B70-35FF-474D-9F53-FC6E1BD8D9C0@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Jun 3, 2026, at 14:58, jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> On Tue, Jun 2, 2026 at 2:40 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)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 before the 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 | Content-Type | Size |
|---|---|---|
| v6-0001-Prevent-inherited-CHECK-constraints-from-being-we.patch | application/octet-stream | 23.2 KB |
| v6-0002-doc-Clarify-inherited-constraint-behavior.patch | application/octet-stream | 3.7 KB |
| v6-0003-doc-Clarify-ALTER-CONSTRAINT-enforceability-behav.patch | application/octet-stream | 2.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-06-03 08:18:47 | Re: Fix regression in vacuumdb --analyze-in-stages for partitioned tables |
| Previous Message | Daniel Gustafsson | 2026-06-03 08:14:47 | Re: Use TEXT_DUMP_HEADER macro instead of hard-coded string in pg_backup_archiver.c |