Re: [PATCH] psql: add \dcs to list all constraints

From: Tatsuro Yamada <yamatattsu(at)gmail(dot)com>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Subject: Re: [PATCH] psql: add \dcs to list all constraints
Date: 2026-01-10 03:14:33
Message-ID: CAOKkKFsBB0aObwCKk=RWrY7HL97K+xQ1kUVh_w4uEGg1h_yUBA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Jim,

Thank you for your review.

On Sat, Jan 3, 2026 at 4:51 AM Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> wrote:
>I've been playing with a few edge cases and everything seems to work
>just fine. Bellow I am listing the cases I tested, so that you can take
>a look if some of them should be included in the regression tests - not
>sure if it is necessary, since this feature is only reading the
>constraint definitions from the catalog.

The original regression tests only covered simple cases, so the more
complex edge cases you tried were very helpful.

The method for converting constraints into definition strings in \dcs uses
the same function as \d (i.e., pg_catalog.pg_get_constraintdef), so I don’t
think there are any major issues there.

>One nitpick: the order of the constraints is different from the one in \d+:
>For consistency, it would be nice to have both options listing in the
>same order, but in case it would mean adding too much complexity to the
>code, I'd say it is just fine as-is.

Regarding the constraint display order, I hadn’t noticed that it differed
between \d and \dcs. Thanks for pointing that out.
In \dcs, constraints are sorted in ascending order by both schema name
and constraint name.
On the other hand, \d appears to use the column number as one of the
sorting keys. I believe this difference explains the discrepancy in the
display order.
As you suggested, I’d like to keep the current behavior to avoid adding
unnecessary complexity.

The next patch will include the following:
- Rebased version
- Expanded regression tests (kept to a minimum)

Regards,
Tatsuro Yamada

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-01-10 04:03:38 Re: Inconsistent terminology for -j/--jobs option in documentation
Previous Message Tatsuro Yamada 2026-01-10 02:48:21 Inconsistent terminology for -j/--jobs option in documentation