Re: ALTER DOMAIN ADD NOT NULL NOT VALID

jian he <jian.universality@gmail.com>

From: jian he <jian.universality@gmail.com>
To: Kirill Reshke <reshkekirill@gmail.com>
Cc: Quan Zongliang <quanzongliang@yeah.net>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-09-24T03:25:23Z
Lists: pgsql-hackers

Attachments

hi.

please check the attached latest version.

I did some minor cosmetic changes.
similar to commit 16a0039, we can just use ShareUpdateExclusiveLock to validate
existing not-valid not null constraints

for the below issue (should the last UPDATE fail or not),
I have already created a thread at [1].
--------------
create domain d1 as int;
create table dt1(i int, c d1);
insert into dt1 values(1,2);
alter domain d1 add constraint cc check(value <> 2) not valid;
update dt1 set i = i + 1;
--------------

[1]: https://postgr.es/m/CACJufxE2oFcLmrqDrqJrH5k03fv+v9=+-PBs-mV5WsJ=31XMyw@mail.gmail.com

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Reduce lock level for ALTER DOMAIN ... VALIDATE CONSTRAINT