Re: UPDATE run check constraints for affected columns only

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: UPDATE run check constraints for affected columns only
Date: 2026-03-04 01:04:49
Message-ID: CACJufxF90yh_BNN9=mVKuF+GNYkqTXgQqWU9QZS7=rdP4kRjxw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 23, 2026 at 10:09 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> code has been further simplified and is now more neat.
> The test is kind of verbose now.
>

if (check_attrs &&
!bms_is_member(-FirstLowInvalidHeapAttributeNumber, check_attrs) &&
!bms_overlap(check_attrs, updatedCols))
{
ereport(DEBUG1,
errmsg_internal("skipping verification for constraint
\"%s\" on table \"%s\"",
check[i].ccname,
RelationGetRelationName(rel)));
}

We need tests to reach the above ereport(DEBUG1, branch.

We can use
+SET log_statement to NONE;
+SET client_min_messages TO 'debug1';

to make sure the regress output has the DEBUG1 message.

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

Attachment Content-Type Size
v4-0001-skip-unnecessary-check-constraint-verification-for-UPDATE.patch text/x-patch 14.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-03-04 01:13:03 Re: Funny behavior in event trigger code with CREATE OR REPLACE VIEW and column additions
Previous Message Xuneng Zhou 2026-03-04 01:02:29 Re: Add pg_stat_recovery system view