UPDATE with invalid domain constraint - Mailing list pgsql-hackers

From jian he
Subject UPDATE with invalid domain constraint
Date
Msg-id CACJufxE2oFcLmrqDrqJrH5k03fv+v9=+-PBs-mV5WsJ=31XMyw@mail.gmail.com
Whole thread Raw
Responses Re: UPDATE with invalid domain constraint
List pgsql-hackers
hi.

should UPDATE statement need to verify that the domain value is satisfied with
invalid domain constraints?
Álvaro Herrera already mentioned this in [1], but I just want to confirm it.

drop table if exists dt1;
drop domain if exists d1;
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;
update dt1 set c = c;
update dt1 set i = i + 1, c = c;
update dt1 set i = i + 1, c = c::d1;

Should the four statements above result in an error?
This only happens with UPDATE, since INSERT will check with domain
invalid constraints.

this ``update dt1 set i = i + 1, c = 2;``
do return error, which is expected.

[1]: https://postgr.es/m/202508140957.4daktvyr7xiw@alvherre.pgsql



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: VM corruption on standby
Next
From: Nazir Bilal Yavuz
Date:
Subject: Re: Speed up COPY FROM text/CSV parsing using SIMD