Re: Catalog domain not-null constraints

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, vignesh C <vignesh21(at)gmail(dot)com>
Subject: Re: Catalog domain not-null constraints
Date: 2024-03-26 09:04:20
Message-ID: CAEZATCXM+Fgw7Ge8ApzmG1Z_FZR1psNXWb3K_QuSk6zgOwGA7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 26 Mar 2024 at 07:30, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
> On 2024-Mar-25, Dean Rasheed wrote:
>
> > Also (not this patch's fault), psql doesn't seem to offer a way to
> > display domain constraint names -- something you need to know to drop
> > or alter them. Perhaps \dD+ could be made to do that?
>
> Ooh, I remember we had offered a patch for \d++ to display these
> constraint names for tables, but didn't get around to gather consensus
> for it. We did gather consensus on *not* wanting \d+ to display them,
> but we need *something*. I suppose we should do something symmetrical
> for tables and domains. How about \dD++ and \dt++?
>

Personally, I quite like the fact that \d+ displays NOT NULL
constraints, because it puts them on an equal footing with CHECK
constraints. However, I can appreciate that it will significantly
increase the length of the output in some cases.

With \dD it's not so nice because of the way it puts all the details
on one line. The obvious output might look something like this:

\dD
List of domains
Schema | Name | Type | Collation | Nullable | Default | Check
--------+------+---------+-----------+----------+---------+-------------------
public | d1 | integer | | NOT NULL | | CHECK (VALUE > 0)

\dD+
List of domains
Schema | Name | Type | Collation | Nullable
| Default | Check | Access privileges
| Description
--------+------+---------+-----------+---------------------------------+---------+---------------------------------------+-------------------+-------------
public | d1 | integer | | CONSTRAINT d1_not_null NOT NULL
| | CONSTRAINT d1_check CHECK (VALUE > 0) |
|

So you'd need quite a wide window to easily view it (or use \x). I
suppose the width could be reduced by dropping the word "CONSTRAINT"
in the \dD+ case, but it's probably still going to be wider than the
average window.

Regards,
Dean

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2024-03-26 09:04:33 Re: pgsql: Track last_inactive_time in pg_replication_slots.
Previous Message Bharath Rupireddy 2024-03-26 08:57:17 Re: Introduce XID age and inactive timeout based replication slot invalidation