i jian, Chao, Thanks for the reviews.
1. jian, you are right, that was inconsistent. In v2, ALTER CONSTRAINT ... ENFORCED on the parent fails with "conflicts with NOT VALID constraint on child table", the error that ALTER TABLE ... INHERIT already gives here. The user validates the child first. So nothing becomes valid behind the user's back, and this does not depend on the question Chao raised. 2. Yes, 18 has it too, the first mail said so. 0002 fixes your partition example as well. 3. Dumping the child's constraint as local changes the catalog. With your patch, k's c comes back with conislocal = true, so ALTER TABLE p DROP CONSTRAINT c no longer drops it from k. pg_upgrade keeps it inherited today, and your patch makes it local there too. ALTER CONSTRAINT is the only command that gives back an inherited constraint that only the child enforces. Your partition case is real, my 0003 missed it, and pg_upgrade loses it on master too. v2-0003 dumps that constraint before its ancestors' ones, as your patch does, with your test. I added you as co-author. A local NOT VALID child that sorts after the parent still comes back validated. That comes from ADD CONSTRAINT merging into the inherited NOT ENFORCED copy, which Nikolay's patch fixes [1]. [1] https://postgr.es/m/cam527d8qch4q1xv-tftdmm3ebcbie9axfdttthpuogwnyt0...@mail.gmail.com Thanks, Shihao
v2-0002-Keep-a-child-s-ENFORCED-CHECK-when-the-parent-s-c.patch
Description: Binary data
v2-0003-pg_dump-keep-ENFORCED-on-a-child-s-inherited-CHEC.patch
Description: Binary data
v2-0001-Reject-enforcing-a-parent-CHECK-over-a-NOT-VALID-.patch
Description: Binary data
