Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails
Alvaro Herrera <alvherre@alvh.no-ip.org>
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Tender Wang <tndrwang@gmail.com>
Cc: Junwang Zhao <zhjwpku@gmail.com>, Jehan-Guillaume de Rorthais <jgdr@dalibo.com>,
"pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, Alexander Lakhin <exclusion@gmail.com>,
Baehler Thomas SBB CFF FFS <thomas.baehler2@sbb.ch>, Guillaume Lelarge <guillaume@lelarge.info>
Date: 2024-08-21T22:00:46Z
Lists: pgsql-hackers
Attachments
- v14-0001-drop-constraint-when-detaching.patch (text/x-diff)
On 2024-Aug-19, Alvaro Herrera wrote: > I haven't pushed it yet, mostly because of being unsure about not doing > anything for the oldest branches (14 and back). Last night, after much mulling on this, it occurred to me that one easy way out of this problem for the old branches, without having to write more code, is to simply remove the constraint from the partition when it's detached (but only if they reference a partitioned relation). It's not a great solution, but at least we're no longer leaving bogus catalog entries around. That would be like the attached patch, which was cut from 14 and applies cleanly to 12 and 13. I'd throw in a couple of tests and call it a day. (TBH the idea of leaving the partition without a foreign key feels to me like travelling in a car without a seat belt -- it feels instinctively dangerous. This is why I went such lengths to keep FKs on detach initially. But I'm not inclined to spend more time on this issue. However ... what about fixing catalog content that's already broken after past detach ops?) -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
Commits
-
Fix some more bugs in foreign keys connecting partitioned tables
- f7d510a38245 16.5 landed
- 936ab6de9595 17.1 landed
- 2d5fe514052a 18.0 landed
- 1b216fceffe3 15.9 landed
-
Restructure foreign key handling code for ATTACH/DETACH
- d20194cead75 13.17 landed
- 5d83bad6b87d 15.9 landed
- 5914a22f6ea5 17.1 landed
- 53af9491a043 18.0 landed
- 46a8c27a7226 14.14 landed
- 2aaf2a28b87e 16.5 landed
-
Create foreign key triggers in partitioned tables too
- f4566345cf40 15.0 cited