Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails
Date
Msg-id 202407191318.uecnw7oaidhu@alvherre.pgsql
Whole thread Raw
In response to Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails  (Tender Wang <tndrwang@gmail.com>)
Responses Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails
Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails
List pgsql-hackers
Hello,

I think the fix for the check triggers should be as the attached.  Very
close to what you did, but you were skipping some operations that needed
to be kept.  AFAICS this patch works correctly for the posted cases.

I haven't looked at the action triggers yet; I think we need to create
one trigger for each partition of the referenced side, so we need to
loop instead of doing a single one.



I find this pair of queries useful; they show which constraints exist
and which triggers belong to each.  We need to make the constraints and
triggers match after a detach right as things would be if the
just-detached partition were an individual table having the same foreign
key.


-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"People get annoyed when you try to debug them."  (Larry Wall)

Attachment

pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: Can we use parallel workers to create index without active/transaction snapshot?
Next
From: Christoph Berg
Date:
Subject: Re: Set log_lock_waits=on by default