Re: partitioned tables referenced by FKs
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Amit Langote <amitlangote09@gmail.com>,
Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2019-03-29T13:56:09Z
Lists: pgsql-hackers
On Wed, Mar 20, 2019 at 11:58 AM Alvaro Herrera <alvherre@2ndquadrant.com> wrote: > constraint is dropped. I can only think of ugly data structure to > support this, and adding enough hooks in dependency.c to support this is > going to be badly received. I don't know why dependency.c doesn't handle this internally. If I say that I want to delete a list of objects, some of which can't be dropped without dropping certain other things, dependency.c ought to be able to suspend judgement on what the problems are until it's looked over that whole list. It seems to me that we've had to fight with this problem before, and I don't know why every individual bit of code that calls into that file has to be responsible for working around it individually. > I think a better idea is to prevent DROP of a partition that's > referenced by a foreign key, period. We would only allow ALTER..DETACH > (they can drop the partition once it's detached). It seems to me that > the check can be done more naturally during detach than during drop, > because we're not constrained to do it within the dependency.c system. IMHO, that sucks a lot. Maybe we should live with it anyway, but it does suck. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Commits
-
Support foreign keys that reference partitioned tables
- f56f8f8da6af 12.0 landed
-
Fix partitioned index creation bug with dropped columns
- 7009f1a2df65 11.3 landed
- 126d63122232 12.0 landed
-
Improve psql's \d display of foreign key constraints
- 1af25ca0c2d9 12.0 cited
-
Fix dependency recording bug for partitioned PKs
- 7e7c57bbb2eb 12.0 landed
-
Add index_get_partition convenience function
- a6da0047158b 12.0 landed
-
Restore RI trigger sanity check
- 815b20ae0c6e 12.0 landed
- 04f9b449aa30 11.3 landed
-
Foreign keys on partitioned tables
- 3de241dba86f 11.0 cited