Re: [PATCH] psql: add \dcs to list all constraints - Mailing list pgsql-hackers

From Tatsuro Yamada
Subject Re: [PATCH] psql: add \dcs to list all constraints
Date
Msg-id CAOKkKFsBB0aObwCKk=RWrY7HL97K+xQ1kUVh_w4uEGg1h_yUBA@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] psql: add \dcs to list all constraints  (Jim Jones <jim.jones@uni-muenster.de>)
List pgsql-hackers
Hi Jim,

Thank you for your review.

On Sat, Jan 3, 2026 at 4:51 AM Jim Jones <jim.jones@uni-muenster.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

pgsql-hackers by date:

Previous
From: Tatsuro Yamada
Date:
Subject: Inconsistent terminology for -j/--jobs option in documentation
Next
From: Michael Paquier
Date:
Subject: Re: Inconsistent terminology for -j/--jobs option in documentation