pgsql: Improve psql's \d display of foreign key constraints

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve psql's \d display of foreign key constraints
Date: 2019-03-26 14:27:40
Message-ID: E1h8n3E-0003Sb-J0@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1af25ca0c2d9d110bd7bd5be2a14fb20cd93ee78

Modified Files
--------------
src/bin/psql/describe.c | 156 ++++++++++++++++++++++--------
src/test/regress/expected/foreign_key.out | 38 +++++---
src/test/regress/sql/foreign_key.sql | 2 +
3 files changed, 145 insertions(+), 51 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2019-03-26 14:46:47 Re: pgsql: Get rid of backtracking in jsonpath_scan.l
Previous Message Tom Lane 2019-03-26 14:21:25 Re: pgsql: Get rid of backtracking in jsonpath_scan.l