Re: partitioned tables referenced by FKs

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: partitioned tables referenced by FKs
Date: 2018-11-30 19:12:16
Message-ID: 20181130191216.5xcxcsx3ascgqayv@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Here's a more credible version of this patch series.

0001 refactors some duplicative code that interprets a pg_constraint row
for a foreign key back into a Constraint node. Only what is necessary
for current features is read.

0002 moves some code that I added in 3de241dba86f to
src/backend/catalog/pg_constraint.c so that it appears in tablecmds.c
instead. After developing the current patch I realized that the latter
is its natural home.

0003 changes the shape of a loop in deleteObjectsInList, so that I can
add object type-specific functions to be called before deleting an
object. This is needed by 0004 and makes no sense on its own; I would
probably push both together, but splitting it like this makes it very
obvious what it is I'm doing.

0004 adds the feature itself

In 0004 there's also a new function "index_get_partition" which allows
to simplify some code I added in 8b08f7d4820f. I will probably split it
up and commit separately because it's an obvious code beautify.

0005 modifies psql to show the constraint in a different way, which
makes more sense overall (rather than show the "internal" constraint
that concerns the partition, show the top-level contraint that concerns
the ancestor table on which it is defined. This includes naming the
table in which the constraint is defined).

There's one half of 0005 that I think should be applied to pg11, because
when partitions have foreign keys, the display looks a bit odd
currently. The other half I would probably merge into 0004 instead of
committing separately. Even if not backpatched, it makes sense to apply
ahead of the rest because it changes expected output for a regression

Álvaro Herrera
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-Refactor-DeconstructConstraintRow.patch text/x-diff 15.9 KB
0002-move-CloneForeignKeyConstraints-to-tablecmds.c.patch text/x-diff 20.6 KB
0003-Rework-deleteObjectsInList-to-allow-objtype-specific.patch text/x-diff 2.2 KB
0004-Support-foreign-key-referencing-partitioned-tables.patch text/x-diff 69.8 KB
0005-Have-psql-not-display-redundant-FKs.patch text/x-diff 9.5 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2018-11-30 19:18:18 Re: pgsql: Switch pg_verify_checksums back to a blacklist
Previous Message Pavel Stehule 2018-11-30 19:06:47 Re: ToDo: show size of partitioned table