Re: cataloguing NOT NULL constraints - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: cataloguing NOT NULL constraints
Date
Msg-id 20230228191537.x4sepwytcclxpl3j@alvherre.pgsql
Whole thread Raw
In response to cataloguing NOT NULL constraints  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: cataloguing NOT NULL constraints
Re: cataloguing NOT NULL constraints
Re: cataloguing NOT NULL constraints
Re: cataloguing NOT NULL constraints
List pgsql-hackers
So I reworked this to use a new contype value for the NOT NULL
pg_constraint rows; I attach it here.  I think it's fairly clean.

0001 is just a trivial change that seemed obvious as soon as I ran into
the problem.

0002 is the most interesting part.

Things that are curious:

- Inheritance and primary keys.  If you have a table with a primary key,
and create a child of it, that child is going to have a NOT NULL in the
column that is the primary key.

- Inheritance and plain constraints.  It is not allowed to remove the
NOT NULL constraint from a child; currently, NO INHERIT constraints are
not supported.  I would say this is an useless feature, but perhaps not.

0003:
Since nobody liked the idea of listing the constraints in psql \d's
footer, I changed \d+ so that the "not null" column shows the name of
the constraint if there is one, or the string "(primary key)" if the
attnotnull marking for the column comes from the primary key.  The new
column is going to be quite wide in some cases; if we want to hide it
further, we could add the mythical \d++ and have *that* list the
constraint name, keeping \d+ as current.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"Los trabajadores menos efectivos son sistematicamente llevados al lugar
donde pueden hacer el menor daño posible: gerencia."  (El principio Dilbert)

Attachment

pgsql-hackers by date:

Previous
From: Jacob Champion
Date:
Subject: Re: Experiments with Postgres and SSL
Next
From: Andres Freund
Date:
Subject: Re: Non-superuser subscription owners