On Fri, Jul 4, 2025 at 8:00 AM jian he <jian.universality@gmail.com> wrote:
>
> On Mon, Jun 2, 2025 at 9:57 PM jian he <jian.universality@gmail.com> wrote:
> >
> > Currently in pg18, we can add not enforced check constraints.
> > but we can not do ALTER TABLE ALTER CONSTRAINT [NOT] ENFORCED
> > for check constraint.
> >
> > The attached patch is implementation of changing enforceability of
> > check constraint.
>
Initial look and testing looks good. There are some odd parts to work
through with partitioned tables and recursion (for example, if you
have a parent unenforced, and a child enforced, setting a parent
enforced and then not enforced will recurse to the child, so you end
up in a different state. that could be surprising, but the alternative
is not obviously more sensicle).
Some minor items below:
+ errhint("Only foreign key, check constraint can change enforceability"));
"Only foreign key and check constraints can change enforceability"
--
+ /*
+ * If we are told not to recurse, there had better not be any child
+ * tables, because we can't changing constraint enforceability on
+ * the parent unless we have chaned enforceability for all child
+ * tables.
+ */
* tables, because we can't change constraint enforceability on
* the parent unless we have changed enforceability for all child
--
+ 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?
Robert Treat
https://xzilla.net