pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Reduce lock level for ALTER DOMAIN ... VALIDATE CONSTRAINT
Date: Fri, 22 Aug 2025 07:00:53 +0000
Message-ID: <E1upLlc-00162U-1r@gemulon.postgresql.org> (raw)

Reduce lock level for ALTER DOMAIN ... VALIDATE CONSTRAINT

Reduce from ShareLock to ShareUpdateExclusivelock.  Validation during
ALTER DOMAIN ... ADD CONSTRAINT keeps using ShareLock.

Example:

    create domain d1 as int;
    create table t (a d1);
    alter domain d1 add constraint cc10 check (value > 10) not valid;

    begin;
    alter domain d1 validate constraint cc10;

    -- another session
    insert into t values (8);

Now we should still be able to perform DML operations on table t while
the domain constraint is being validated.  The equivalent works
already on table constraints.

Author: jian he <jian.universality@gmail.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CACJufxHz92A88NLRTA2msgE2dpXpE-EoZ2QO61od76-6bfqurA%40mai...

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/16a0039dc0d1d0cdfadaf38cd3a30f3c8f590c48

Modified Files
--------------
src/backend/commands/typecmds.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)



Message-ID: <E1upLlc-00162U-1r@gemulon.postgresql.org>
Permalink:  ../E1upLlc-00162U-1r@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1upLlc-00162U-1r@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Reduce lock level for ALTER DOMAIN ... VALIDATE CONSTRAINT
  In-Reply-To: <E1upLlc-00162U-1r@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox