public inbox for [email protected]  
help / color / mirror / Atom feed
Re: BUG #19420: Zombie FK exists after partition is detached.
2+ messages / 2 participants
[nested] [flat]

* Re: BUG #19420: Zombie FK exists after partition is detached.
@ 2026-02-27 14:45  Laurenz Albe <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Laurenz Albe @ 2026-02-27 14:45 UTC (permalink / raw)
  To: [email protected]; [email protected]

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






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #19420: Zombie FK exists after partition is detached.
@ 2026-02-27 14:50  Agnieszka Chodkowska-Gyurics <[email protected]>
  parent: Laurenz Albe <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Agnieszka Chodkowska-Gyurics @ 2026-02-27 14:50 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: [email protected]

I'm thinking about that too, but I wanted to make sure there wasn't a
better solution first.

pt., 27 lut 2026 o 15:45 Laurenz Albe <[email protected]> napisał(a):

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


-- 
Zapraszam na moją stronę www. <http://www.nureczka.pl;


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-02-27 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-02-27 14:45 Re: BUG #19420: Zombie FK exists after partition is detached. Laurenz Albe <[email protected]>
2026-02-27 14:50 ` Agnieszka Chodkowska-Gyurics <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox