Re: Fix bug of CHECK constraint enforceability recursion

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(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-01 15:51:54
Message-ID: CACJufxHbVuY683j3DHEU4LSswo8DTzLJbTvhv2Uj6gqN8pJs7Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi.

I did some refactoring based on your v3, I didn't change your comments.

I don't think ATGetEquivalentCheckConstraintOid is necessary.
ATCheckCheckConstrHasEnforcedParent,
AlterCheckConstrEnforceabilityRecurse is enough for this context.

+ changing_conids = lappend_oid(list_copy(changing_conids),
+ currcon->oid);
Refactor changing_conids to List ** to allow direct modification,
aligning with existing code conventions.

CREATE TABLE ... PARTITION OF automatically copies the parent's status, and
ALTER TABLE ... ATTACH PARTITION already rejects cases where the parent is
enforced but the child is not. If we also reject directly altering a partition's
constraint enforcement status, then we need no longer worry about cases where
parent being enforced while a child is not. Therefore, invoking
ATCheckCheckConstrHasEnforcedParent just once for table partitioning is safe.

--
jian
https://www.enterprisedb.com/

Attachment Content-Type Size
v4-0001-Prevent-inherited-CHECK-constraints-from-being-weakened.patch text/x-patch 20.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Lucas Jeffrey 2026-06-01 16:02:43 Re: [PATCH] Fix segmentation fault caused by reentrancy in RI_Fkey_cascade_del (ri_triggers.c)
Previous Message Jacob Champion 2026-06-01 15:46:52 Re: sandboxing untrusted code