Re: pg_upgrade fails when FK constraint with same name exists on partitioned table and its partition - Mailing list pgsql-hackers

From Álvaro Herrera
Subject Re: pg_upgrade fails when FK constraint with same name exists on partitioned table and its partition
Date
Msg-id aihVOD_Q23zuHBE1@alvherre.pgsql
Whole thread
In response to pg_upgrade fails when FK constraint with same name exists on partitioned table and its partition  (Arseny Kositsin <a.kositsyn@postgrespro.ru>)
List pgsql-hackers
On 2026-Jun-08, Arseny Kositsin wrote:

> ALTER TABLE ONLY xxi.trn_part1
> ADD CONSTRAINT fk_trn_acc FOREIGN KEY (acc_id) REFERENCES xxi.acc(id) NOT
> VALID;
>
> ALTER TABLE xxi.trn
> ADD CONSTRAINT fk_trn_acc FOREIGN KEY (acc_id) REFERENCES xxi.acc(id);

So why not just drop the constraint in the partition?  Seems rather
useless.  If there's a valid reason to have a constraint that's
different from the one in the parent table, then you can rename it.

I guess we could add a check to "pg_upgrade --check" to report this kind
of thing ... I'm not really convinced of this though.  Anyhow, I don't
feel inclined to try to have pg_upgrade/pg_dump handle this case cleanly.

-- 
Álvaro Herrera



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Fix missing semicolon in pl_gram.y for option_value rule
Next
From: "Jonathan Gonzalez V."
Date:
Subject: Re: Add pg_get_publication_ddl function