| 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-05-26 08:32:29 |
| Message-ID: | CACJufxGxY=1mxcNz8-bjp6R+ZoCRE3O7DYt2ZqObv-Le+aMOqw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, May 26, 2026 at 3:47 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)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)));
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-disallow-alter-enforciability-of-inherited-check-constraint.patch | text/x-patch | 5.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Guo | 2026-05-26 08:48:24 | Fix HAVING-to-WHERE pushdown with mismatched operator families |
| Previous Message | Daniel Gustafsson | 2026-05-26 08:16:40 | Re: PostgreSQL and OpenSSL 4.0.0 |