Re: Catalog domain not-null constraints

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Aleksander Alekseev <aleksander(at)timescale(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: Catalog domain not-null constraints
Date: 2023-11-23 16:35:25
Message-ID: 202311231635.3fhdzfa455kc@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2023-Nov-23, Aleksander Alekseev wrote:

> Interestingly enough according to the documentation this syntax is
> already supported [1][2], but the actual query will fail on `master`:
>
> ```
> =# create domain connotnull integer;
> CREATE DOMAIN
> =# alter domain connotnull add not null value;
> ERROR: unrecognized constraint subtype: 1
> ```

Hah, nice ... this only fails in this way on master, though, as a
side-effect of previous NOT NULL work during this cycle. So if we take
Peter's patch, we don't need to worry about it. In 16 it behaves
properly, with a normal syntax error.

> ```
> =# create domain connotnull1 integer;
> =# create domain connotnull2 integer;
> =# alter domain connotnull1 add not null value;
> =# alter domain connotnull2 set not null;
> =# \dD
> ERROR: unexpected null value in cached tuple for catalog
> pg_constraint column conkey
> ```

This is also a master-only problem, as "add not null" is rejected in 16
with a syntax error (and obviously \dD doesn't fail).

> NOT VALID is not supported:
>
> ```
> =# alter domain connotnull add not null value not valid;
> ERROR: NOT NULL constraints cannot be marked NOT VALID
> ```

Yeah, it'll take more work to let NOT NULL constraints be marked NOT
VALID, both on domains and on tables. It'll be a good feature for sure.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"La victoria es para quien se atreve a estar solo"

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2023-11-23 16:38:30 Re: Catalog domain not-null constraints
Previous Message Bruce Momjian 2023-11-23 16:12:30 Re: [HACKERS] psql casts aspersions on server reliability