Re: Reduce lock level for ALTER TABLE ... ADD CHECK .. NOT VALID

From: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
To: Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Reduce lock level for ALTER TABLE ... ADD CHECK .. NOT VALID
Date: 2021-07-10 13:49:58
Message-ID: CAFBsxsH4=TT7zv3R4d7-JKrLymG6Ow8GaiwBvVcVsQG8YwJf0g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Apr 22, 2021 at 8:01 AM Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>
wrote:
>
> 897795240cfaaed724af2f53ed2c50c9862f951f forgot to reduce the lock
> level for CHECK constraints when allowing them to be NOT VALID.
>
> This is simple and safe, since check constraints are not used in
> planning until validated.

The patch also reduces the lock level when NOT VALID is not specified,
which didn't seem to be the intention.

# begin;
BEGIN
*# alter table alterlock2 add check (f1 > 0);
ALTER TABLE
*# select * from my_locks order by 1;
relname | max_lockmode
------------+-----------------------
alterlock2 | ShareRowExclusiveLock
(1 row)

--
John Naylor
EDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2021-07-10 14:49:13 Re: psql - factor out echo code
Previous Message Bharath Rupireddy 2021-07-10 13:39:10 Re: bugfix: when the blocksize is 32k, the function page_header of pageinspect returns negative numbers.