Re: Allow NOT VALID foreign key constraints on partitioned tables.
Amul Sul <sulamul@gmail.com>
From: Amul Sul <sulamul@gmail.com>
To: Álvaro Herrera <alvherre@alvh.no-ip.org>
Cc: "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2025-01-22T06:12:15Z
Lists: pgsql-hackers
Attachments
- v3-0002-Allow-NOT-VALID-foreign-key-constraints-on-partit.patch (application/octet-stream) patch v3-0002
On Wed, Jan 22, 2025 at 2:36 AM Álvaro Herrera <alvherre@alvh.no-ip.org> wrote: > > > Suppose I have a hierarchy like this > > parent > | > child > /\ > / \ > / grandchild2 > / > grandchild1 > > and I have a validated constraint on grandchild1 and an invalid > constraint on child. What happens if I add a constraint on parent? In > my understanding, it should not attempt to revalidate the constraint on > grandchild1, because it's known valid; but I don't think I see code that > would skip validation there. That is, QueueFKConstraintValidation does > its thing unconditionally (esp. recursing to children), which seems > wrong. > You’re correct; it’s fixed in the attached version, along with an assert(!convalidated) in QueueFKConstraintValidation(), and I’ve included tests to cover the change. Thanks for reviewing this patch. Regards, Amul
Commits
-
Add missing CommandCounterIncrement
- 0a16c8326c5a 18.0 landed
-
Fix instability in recently added regression tests
- c44c2d275987 18.0 landed
-
Allow NOT VALID foreign key constraints on partitioned tables
- b663b9436e75 18.0 landed
-
Split ATExecValidateConstraint into reusable pieces
- 86374c9a0e30 18.0 landed