Re: Issue attaching a table to a partitioned table with an auto-referenced foreign key

From: Alvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Tender Wang <tndrwang(at)gmail(dot)com>
Cc: Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com>, fastcat(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Christoph Berg <myon(at)debian(dot)org>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>, Guillaume Lelarge <guillaume(at)lelarge(dot)info>, Luca Vallisa <luca(dot)vallisa(at)gmail(dot)com>
Subject: Re: Issue attaching a table to a partitioned table with an auto-referenced foreign key
Date: 2025-05-03 13:09:23
Message-ID: 202505031309.f3pavc23a5b3@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On 2025-May-01, Tender Wang wrote:

> Hmm. I didn't get the same conclusion.
> Before commit 5914a22f6ea5, the issue reported by Luca could have happened.
[...]
> You can see from the above test that no error was reported.
> But if I revert the commit 614a406b4ff1, above test would report error on
> v16devel:

Yeah, I was mistaken to blame 5914a22f6ea5 for this issue when the real
culprit was 614a406b4ff1. Anyway, I pushed the proposed fix to all
branches last night, so hopefully it works correctly for all cases now.

(As context -- it took me several weeks or months to get FKs on
partitioned tables to work. People would make fun at the "spider"
diagrams I drew on whiteboards, of the relationships between
pg_constraint and pg_trigger entries. And for some reason at no point
did the idea of self-referencing FKs occurred to me. I should have
realized that the complexity was getting out of hand! At the very least
I should have pressed for some more QA help.)

Y'all are still on time to test this a bit more before next week's
releases ... if I have made things even worse I can still revert the
patch. With luck, that won't be necessary.

Regards

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"Java is clearly an example of money oriented programming" (A. Stepanov)

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Sergey Koposov 2025-05-03 16:11:35 Re: BUG #18909: Query creates millions of temporary files and stalls
Previous Message Alexander Lakhin 2025-05-03 05:00:00 Re: BUG #18741: Detaching a partition referencing a partitioned table fails with a trigger-related error

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2025-05-03 13:57:36 Re: Logical Replication of sequences
Previous Message Etsuro Fujita 2025-05-03 11:19:55 Re: Thinko in pgstat_build_snapshot()