Improve psql's \d display of foreign key constraints

Alvaro Herrera <alvherre@alvh.no-ip.org>

Commit: 1af25ca0c2d9d110bd7bd5be2a14fb20cd93ee78
Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: 2019-03-26T14:14:34Z
Releases: 12.0
Improve psql's \d display of foreign key constraints

When used on a partition containing foreign keys coming from one of its
ancestors, \d would (rather unhelpfully) print the details about the
pg_constraint row in the partition.  This becomes a bit frustrating when
the user tries things like dropping the FK in the partition; instead,
show the details for the foreign key on the table where it is defined.

Also, when a table is referenced by a foreign key on a partitioned
table, we would show multiple "Referenced by" lines, one for each
partition, which gets unwieldy pretty fast.  Modify that so that it
shows only one line for the ancestor partitioned table where the FK is
defined.

Discussion: https://postgr.es/m/20181204143834.ym6euxxxi5aeqdpn@alvherre.pgsql
Reviewed-by: Tom Lane, Amit Langote, Peter Eisentraut

Files

Discussion