Re: BUG #19420: Zombie FK exists after partition is detached. - Mailing list pgsql-bugs

From Laurenz Albe
Subject Re: BUG #19420: Zombie FK exists after partition is detached.
Date
Msg-id 1b32a18349afe49d4cc605a91b8f900e4f9e1ad1.camel@cybertec.at
Whole thread Raw
In response to BUG #19420: Zombie FK exists after partition is detached.  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #19420: Zombie FK exists after partition is detached.
List pgsql-bugs
On Fri, 2026-02-27 at 09:09 +0000, PG Bug reporting form wrote:
> Logged by:          Agnieszka Chodkowska
> PostgreSQL version: 16.6
> Operating system:   Linux, Debian 12.2.0 64 bit
>
> I have child table  with FK defined as folllows
>
> ALTER TABLE IF EXISTS tst.child_test_1
>     ADD CONSTRAINT child_test_1_parent_id_parent_part_by_fkey FOREIGN KEY
> (parent_id, parent_part_by)
>     REFERENCES tst.maintenance_test_1_p20260218 (id, part_by) MATCH SIMPLE
>     ON UPDATE NO ACTION
>     ON DELETE CASCADE;

This is a table partition with a foreign key to another table partition,
correct?

> I updated configuration according to documentation as follows:
> retention_keep_table=false ,
> retention_keep_index = false

These are not PostgreSQL configuration parameters...

> Somehow postgresql retains the foreign keys of the detached/dropped
> partitions, to the parent table partitions.

That is as expected.  partitions are tables in their own right and can
entertain foreign key constraints to other tables, independent of their
role as partitions of a partitioned table.

> I try the following methods:
> partman.run_maintenance('tst.child_test_1')
> partman.run_maintenance()
> ALTER TABLE tst.child_test_1 DETACH PARTITION <child_test_p_20260218>
>
> The error persisted regardless of the method used.

I'd say that you have to drop the foreign key constraint explicitly.

Yours,
Laurenz Albe



pgsql-bugs by date:

Previous
From: Richard Guo
Date:
Subject: Re: BUG #19418: SQL/JSON JSON_VALUE() does not conform to ISO/IEC 9075-2:2023(E) 6.34
Next
From: Agnieszka Chodkowska-Gyurics
Date:
Subject: Re: BUG #19420: Zombie FK exists after partition is detached.