Re: Allow NOT VALID foreign key constraints on partitioned tables.

From: Amul Sul <sulamul(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Allow NOT VALID foreign key constraints on partitioned tables.
Date: 2025-01-22 06:12:15
Message-ID: CAAJ_b97_zJvzmLJS8AAzGFEYAAMbm5KM8ix4VPxaSO=ptkYx6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 22, 2025 at 2:36 AM Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)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

Attachment Content-Type Size
v3-0002-Allow-NOT-VALID-foreign-key-constraints-on-partit.patch application/octet-stream 22.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2025-01-22 06:20:41 Re: Pgoutput not capturing the generated columns
Previous Message Japin Li 2025-01-22 06:09:48 Re: [RFC] Lock-free XLog Reservation from WAL