Re: alter check constraint enforceability
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Robert Treat <rob@xzilla.net>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-08-11T09:53:08Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add support for altering CHECK constraint enforceability
- 342051d73b38 19 (unreleased) landed
-
rename alter constraint enforceability related functions
- a9747153e14d 19 (unreleased) landed
Attachments
- v3-0001-alter-check-constraint-enforceability.patch (text/x-patch) patch v3-0001
On Thu, Aug 7, 2025 at 7:35 AM Robert Treat <rob@xzilla.net> wrote: > > + if (rel->rd_rel->relkind == RELKIND_RELATION && > + cmdcon->is_enforced && > + !currcon->conenforced) > > i think I have convinced myself that this is correct, but maybe I will > ask you if you had any concerns that this needed to also consider > RELKIND_PARTITIONED_TABLE as well? > ATExecAlterCheckConstrEnforceability itself will be recursive to all the children. AlterConstrUpdateConstraintEntry is responsible for changing the catalog state. except the changing the catalog state, if we change the check constraint from NOT ENFORCED to ENFORCED, we also need to verify it in phase 3. that's the purpose of > + if (rel->rd_rel->relkind == RELKIND_RELATION && > + cmdcon->is_enforced && > + !currcon->conenforced) partitioned tables don't have storage, phase3 table scan to verify check constraint on partitioned table don't have effect. also partitioned table check constraint (name, definition (pg_constraint.conbin) must match with partition otherwise partition can be attached to the partitioned table. so here you don't need to consider RELKIND_PARTITIONED_TABLE.