Re: ALTER DOMAIN ADD NOT NULL NOT VALID

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Quan Zongliang <quanzongliang(at)yeah(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: ALTER DOMAIN ADD NOT NULL NOT VALID
Date: 2025-08-14 09:02:27
Message-ID: CALdSSPiUiVya+L-642ffcvVPYWN0kysCeOhy3aho57GzxuYS=g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 14 Aug 2025 at 07:47, jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> hi.
> rebase and minor cosmetic change.

Hi!
It appears satisfactory to me.
I have few observations.
One is whether we should now support CREATE DOMAIN ... NOT NULL NOT
VALID syntax? This could be a separate patch though.
Second observation is just a question:

```

reshke=# create domain dd as int;
CREATE DOMAIN
reshke=# create table dt(i int, c dd);
CREATE TABLE
reshke=# insert into dt values(1,null);
INSERT 0 1
reshke=# alter domain dd add constraint c not null not valid ;
ALTER DOMAIN
reshke=# update dt set i = i + 1;
UPDATE 1
reshke=# update dt set i = i + 1, c =null;
ERROR: domain dd does not allow null values
reshke=# table dt;
i | c
---+---
2 |
(1 row)

```

Is this behaviour correct? Meaning first update is successful while
second is not, yet they would produce the same result.

And last is about psql-tab-complete: we now can complete 'alter domain
... add constraint .. not null' with 'not valid'. This also could be
a separate patch.

--
Best regards,
Kirill Reshke

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Benoit Tigeot 2025-08-14 09:04:27 Re: pg_stat_statements: Add `calls_aborted` counter for tracking query cancellations
Previous Message jian he 2025-08-14 08:59:56 Re: Making jsonb_agg() faster