From: | Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | "Amul Sul" <sulamul(at)gmail(dot)com>, "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-02 18:40:25 |
Message-ID: | c2dcf304-45d6-47c1-8cd3-6ed15aca4da8@app.fastmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Jan 2, 2025, at 5:49 PM, Amul Sul wrote:
> When adding a new FK constraint or attaching a partitioned table, where
> matching FK constraints are merged, we allow the parent constraint to be NOT
> VALID while the child constraint remains VALID, which is harmless. However, the
> reverse scenario -- where the parent constraint is VALID and the child is NOT
> VALID -- is incorrect. To address this, when merging a NOT VALID FK constraint
> from the child with a VALID parent constraint, it implicitly validates the
> child constraint against its existing data and marks it as VALID. This behavior
> aligns with adding a new FK constraint directly to the child table, which would
> also validate the existing data.
Hmm, I'm not sure about this, which may cause surprising delays. Maybe it would be better that the operation fails with an error, so that the user can do VALIDATE CONSTRAINT explicitly and retry the ATTACH once all the partitions have been so processed.
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2025-01-02 19:24:50 | Re: magical eref alias names |
Previous Message | Sami Imseih | 2025-01-02 18:24:06 | POC: track vacuum/analyze cumulative time per relation |