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

From: Álvaro Herrera <[email-masked]>
Date: Thu, 23 Jan 2025 16:04:32 +0100

On 2025-Jan-22, Amul Sul wrote:

> 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.

OK thanks, looks good, I have pushed it now with some trivial
amendments.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"Java is clearly an example of money oriented programming"  (A. Stepanov)

---

From: Alexander Lakhin <[email-masked]>
Date: Sat, 25 Jan 2025 07:00:01 +0200

Hello Álvaro,

> OK thanks, looks good, I have pushed it now with some trivial

Please look at the script that produces an error starting from b663b9436:
CREATE TABLE st (a int, primary key (a));
CREATE TABLE pt (a int,
   FOREIGN KEY (a) REFERENCES st ON DELETE SET NULL ON UPDATE SET NULL,
   FOREIGN KEY (a) REFERENCES st ON DELETE SET NULL ON UPDATE SET NULL
) PARTITION BY LIST (a);
CREATE TABLE tp1 PARTITION OF pt FOR VALUES IN (1, 2);
ALTER TABLE pt DETACH PARTITION tp1;
ALTER TABLE pt ATTACH PARTITION tp1 FOR VALUES IN (1, 2);

ERROR:  XX000: tuple already updated by self
LOCATION:  simple_heap_update, heapam.c:4374

Best regards,
Alexander Lakhin
Neon (https://neon.tech)