Re: Add psql command to list constraints

From: Tatsuro Yamada <tatsuro(dot)yamada(dot)tf(at)nttcom(dot)co(dot)jp>
To: Greg Stark <stark(at)mit(dot)edu>, Robert Haas <robertmhaas(at)gmail(dot)com>, Dag Lem <dag(at)nimrod(dot)no>
Cc: Justin Pryzby <pryzby(at)telsasoft(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(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-03-29 05:21:07
Message-ID: dd4d56ab-7062-bb76-4e4a-31992d20fffa@nttcom.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Dag,

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

Thank you!


> 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.

Fixed.

> * 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);

Oh, you are right! Fixed.


> 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".

I fixed the output columns as you proposed.

The current status of this patch is:

- Addressed Dag's comments
- Not implemented yet:
- Tab completion
- Regression test
- NOT NULL constraint, and so on (based on pg_attribute)

Please find attached new patch.

Thanks,
Tatsuro Yamada

Attachment Content-Type Size
0001-Add-psql-command-to-list-constraints-POC4.patch text/plain 7.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2022-03-29 05:31:57 Re: Identify missing publications from publisher while create/alter subscription.
Previous Message Amit Kapila 2022-03-29 05:13:00 Re: Skipping logical replication transactions on subscriber side