Re: Allow NOT VALID foreign key constraints on partitioned tables.
От | Álvaro Herrera |
---|---|
Тема | Re: Allow NOT VALID foreign key constraints on partitioned tables. |
Дата | |
Msg-id | c2dcf304-45d6-47c1-8cd3-6ed15aca4da8@app.fastmail.com обсуждение исходный текст |
Ответы |
Re: Allow NOT VALID foreign key constraints on partitioned tables.
|
Список | 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, wherematching FK constraints are merged, we allow the parent constraint to be NOTVALID while the child constraint remains VALID, which is harmless. However, thereverse scenario -- where the parent constraint is VALID and the child is NOTVALID -- is incorrect. To address this, when merging a NOT VALID FK constraintfrom the child with a VALID parent constraint, it implicitly validates thechild constraint against its existing data and marks it as VALID. This behavioraligns with adding a new FK constraint directly to the child table, which wouldalso 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.
В списке pgsql-hackers по дате отправления: