Re: Add psql command to list constraints

From: Dag Lem <dag(at)nimrod(dot)no>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Tatsuro Yamada <tatsuro(dot)yamada(dot)tf(at)nttcom(dot)co(dot)jp>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add psql command to list constraints
Date: 2022-02-04 11:39:09
Message-ID: ygeo83meu8y.fsf@sid.nimrod.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:

> On Monday, November 15, 2021, Tatsuro Yamada
> <tatsuro(dot)yamada(dot)tf(at)nttcom(dot)co(dot)jp> wrote:
>
> I don't know if this is a good example, but if you look at
> StackOverflow,
> it seems that people who want to see a list of constraints appear
> regularly.
>
> https://stackoverflow.com/questions/62987794/how-to-list-all-constraints-
> of-a-table-in-postgresql
>
>
> Given the questioner restricted their question to “for a given table”
> I’d say it supports leaving the status quo, not changing it.
>
> If, as you suppose, these come up regularly then finding one that asks
> for it “in the entire database”, ideally with some stated goal, should
> be doable.
>
> David J.
>
>

This is my review of the patch in
https://commitfest.postgresql.org/37/3468/

The patch adds the command "\dco" to list constraints in psql. This
seems useful to me.

The patch applies cleanly to HEAD, although some hunks have rather large
offsets.

As far as I can tell, the "\dco" command works as documented.

I have however found the following issues with the patch:

* A TAB character has been added to doc/src/sgml/ref/psql-ref.sgml -
this should be replaced with spaces.
* The call to listConstraints in line src/bin/psql/command.c 794 refers
to &cmd[2], this should rather be &cmd[3].
* The patch kills the "\dc" command in src/bin/psql/command.c
This can be fixed by adding the following at line 800:
else
success =
listConversions(pattern, show_verbose, show_system);

Another comment is that the "\dco" command outputs quite a lot of
information, which only fits in a wide terminal window. Would it be an
idea to only display the columns "Schema" and "Name" by default, and
use "+" to specify inclusion of the columns "Definition" and "Table".

Best regards

Dag Lem

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2022-02-04 11:45:05 Re: Deparsing rewritten query
Previous Message Peter Smith 2022-02-04 10:56:20 Re: row filtering for logical replication