Re: Add psql command to list constraints - Mailing list pgsql-hackers

From Dag Lem
Subject Re: Add psql command to list constraints
Date
Msg-id ygeo83meu8y.fsf@sid.nimrod.no
Whole thread Raw
In response to Add psql command to list constraints  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Add psql command to list constraints  (Greg Stark <stark@mit.edu>)
List pgsql-hackers
"David G. Johnston" <david.g.johnston@gmail.com> writes:

> On Monday, November 15, 2021, Tatsuro Yamada
> <tatsuro.yamada.tf@nttcom.co.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



pgsql-hackers by date:

Previous
From: Peter Smith
Date:
Subject: Re: row filtering for logical replication
Next
From: Pavel Stehule
Date:
Subject: Re: Deparsing rewritten query