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

From jian he
Subject Re: Fix bug of CHECK constraint enforceability recursion
Date
Msg-id CACJufxGxY=1mxcNz8-bjp6R+ZoCRE3O7DYt2ZqObv-Le+aMOqw@mail.gmail.com
Whole thread
In response to Re: Fix bug of CHECK constraint enforceability recursion  (Chao Li <li.evan.chao@gmail.com>)
Responses Re: Fix bug of CHECK constraint enforceability recursion
List pgsql-hackers
On Tue, May 26, 2026 at 3:47 PM Chao Li <li.evan.chao@gmail.com> wrote:
>
> >
> > I think this is a bug that we need to fix in 19 as well — I mean we should reject the ALTER TABLE.
> >
> > --
> > Álvaro Herrera
>
> Thanks for your comment. Let me rework the patch.
>

Hi.
Here are the comments placed in ATExecAlterCheckConstrEnforceability I
came up with:

+    /*
+     * If the check constraint qual definitions match but their enforcement
+     * statuses conflict (parent enforced, child unenforced), it creates
+     * ambiguity around how insert operations should handle the mismatch.
+     * Therefore, we should avoid states where the parent check constraint is
+     * enforced while the child is not. We actually enforced this within
+     * MergeConstraintsIntoExisting and MergeWithExistingConstraint.
+     */
+    if (currcon->coninhcount > 0 && !recursing)
+        ereport(ERROR,
+                errcode(ERRCODE_INVALID_TABLE_DEFINITION),
+                errmsg("cannot alter inherited constraint \"%s\" of
relation \"%s\" enforciability",
+                       NameStr(currcon->conname),
RelationGetRelationName(rel)));



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

Attachment

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: PostgreSQL and OpenSSL 4.0.0
Next
From: Aleksander Alekseev
Date:
Subject: Re: [PATCH] Little refactoring of portalcmds.c