Re: pg_upgrade fails when FK constraint with same name exists on partitioned table and its partition

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Arseny Kositsin <a(dot)kositsyn(at)postgrespro(dot)ru>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pg_upgrade fails when FK constraint with same name exists on partitioned table and its partition
Date: 2026-06-09 18:06:47
Message-ID: aihVOD_Q23zuHBE1@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonathan Gonzalez V. 2026-06-09 18:17:37 Re: Add pg_get_publication_ddl function
Previous Message Bertrand Drouvot 2026-06-09 18:04:20 Re: Avoid orphaned objects dependencies, take 3