Re: NOT NULL NOT ENFORCED - Mailing list pgsql-hackers

From jian he
Subject Re: NOT NULL NOT ENFORCED
Date
Msg-id CACJufxEBvceJ4Ju=7_LtfcL5ekuXK=AWgOB1vAN_svKRYetgyg@mail.gmail.com
Whole thread
In response to Re: NOT NULL NOT ENFORCED  (Álvaro Herrera <alvherre@kurilemu.de>)
List pgsql-hackers
On Mon, Feb 23, 2026 at 11:50 PM Álvaro Herrera <alvherre@kurilemu.de> wrote:
>
> But what is NOT VALID NOT ENFORCED?  Unless I'm confused, a constraint
> can be in one of three cases,
>
> 1. the normal one (valid and enforced), which is dumped together with
>    the table,
> 2. the NOT ENFORCED one, for which there's no validity marking (these
>    are all in practice invalid, but we don't spell that out because it's
>    pointless to do so), which I argue should also be dumped together
>    with the table,
> 3. NOT VALID but enforced, which is dumped separately, because trying to
>    dump it together with the table just won't work.
>
> I understand that you want to treat 2 the same as 3, because it saves a
> dozen of pg_dump lines of code.  I think it's more user friendly to
> treat 2 the same as 1, and that the dozen lines of code are worth it.
>
Hi.

It turns out that the change for NOT ENFORCED NOT NULL is pg_dump.c is
not complicated.

CREATE TABLE ne_nn_tbl (x int, CONSTRAINT nn NOT NULL x NOT ENFORCED);
Now the pg_dump output is

CREATE TABLE public.ne_nn_tbl (
    x integer CONSTRAINT nn NOT NULL NOT ENFORCED
);

but the 002_pg_dump.pl is failing....



--
jian
https://www.enterprisedb.com/

Attachment

pgsql-hackers by date:

Previous
From: Alexander Lakhin
Date:
Subject: Re: BUG: Former primary node might stuck when started as a standby
Next
From: Chao Li
Date:
Subject: Re: DOC: fixes multiple errors in alter table doc