| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | UPDATE run check constraints for affected columns only |
| Date: | 2025-12-01 06:20:32 |
| Message-ID: | CACJufxEtY1hdLcx=Fhnqp-ERcV1PhbvELG5COy_CZjoEW76ZPQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
hi.
while casually looking at https://wiki.postgresql.org/wiki/Todo
then I found out this thread:
https://postgr.es/m/1326055327.15293.13.camel%40vanquo.pezone.net
Seems easier to do nowadays.
The attached patch implements the $subject.
regress tests seems not enough to test it.
Following the approach in 001_constraint_validation.pl, we use
ereport(DEBUG1, errmsg_internal), then grep the logs to check whether the
enforced constraint verification was skipped or not.
we can not add check constraint to VIEW,
tests covered partitioned table scarenio.
DEMO:
CREATE TABLE upd_check_skip (a int, b int, c int, d int generated
always as (b+c) STORED);
ALTER TABLE upd_check_skip ADD CONSTRAINT cc2 CHECK(a+c < 100);
ALTER TABLE upd_check_skip ADD CONSTRAINT cc3 CHECK(b < 1);
ALTER TABLE upd_check_skip ADD CONSTRAINT cc4 CHECK(d < 2);
INSERT INTO upd_check_skip DEFAULT VALUES;
SET client_min_messages to DEBUG1;
--constraint verification will be skipped for cc3, cc4
UPDATE upd_check_skip SET a = 1;
--constraint verification will be skipped for cc2
UPDATE upd_check_skip SET b = -1;
--constraint verification will be skipped for cc3
UPDATE upd_check_skip SET c = -1;
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-UPDATE-run-check-constraints-for-affected-columns-only.patch | text/x-patch | 10.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Masahiko Sawada | 2025-12-01 06:20:54 | Re: POC: enable logical decoding when wal_level = 'replica' without a server restart |
| Previous Message | Masahiko Sawada | 2025-12-01 06:17:34 | Re: POC: enable logical decoding when wal_level = 'replica' without a server restart |