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

From Robert Haas
Subject Re: Add psql command to list constraints
Date
Msg-id CA+TgmoZuFqU1Ku+NP-cNmEfrHfwry47gY+WadJKbmprERB==qw@mail.gmail.com
Whole thread Raw
In response to Re: Add psql command to list constraints  (Greg Stark <stark@mit.edu>)
Responses Re: Add psql command to list constraints  (Justin Pryzby <pryzby@telsasoft.com>)
List pgsql-hackers
On Fri, Mar 25, 2022 at 12:28 AM Greg Stark <stark@mit.edu> wrote:
> Development of this seems to have stalled with the only review of this
> patch expressing some skepticism about whether it's needed at all.

My opinion on this patch is that we typically handle objects that are
essentially table properties by showing the output in \d+ on the
individual table. And that already works just fine:

rhaas=# create table duck (quack int unique, check (quack > 0));
CREATE TABLE
rhaas=# \d+ duck
                                          Table "public.duck"
 Column |  Type   | Collation | Nullable | Default | Storage |
Compression | Stats target | Description
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
 quack  | integer |           |          |         | plain   |
    |              |
Indexes:
    "duck_quack_key" UNIQUE CONSTRAINT, btree (quack)
Check constraints:
    "duck_quack_check" CHECK (quack > 0)
Access method: heap

Now, there is some precedent for the idea of providing a command that
lists everything globally. Specifically, we have a \dp command, also
known as \z, to list privileges across all objects in the database.
However, I have found that command to be relatively useless, because
if you've got any significant number of grants in the database it just
produces too much output. I think this would have the same problem.
The other thing that we have that is somewhat similar to this is \dd,
which lists comments "for object types which do not have their
comments displayed by their own backslash commands." However, it says
that the object types that it covers are "constraint, operator class,
operator family, rule, and trigger," and that list is out of date,
because operator classes and families got their own backslash commands
two years ago. We could update that, but honestly I can't see anyone
being too excited about a command that lists comments on every
constraint, rule, and trigger in the system: it would be a lot more
useful to show those commands in the \d+ output for the table to which
they are bound, and get rid of \dd (and maybe \dp and \z too).

Now that is not to say that what is being proposed here is completely
useless. It clearly isn't. It's totally debatable whether we ought to
start having commands like this, and maybe we should. It would make
for more commands, and that's not entirely great because the command
names are increasingly alphabet soup. Who can remember what \drds or
\dAc does? Only real power users. If we add more, it's going to get
even more difficult, but some people will use it and like it and those
people will be happy. It's kind of hard to say whether we'd come out
ahead or not. What I think is fairly certain is that it would
represent a reversal of our current policy.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Add non-blocking version of PQcancel
Next
From: Justin Pryzby
Date:
Subject: Re: Add psql command to list constraints