Re: Reduce lock level for ALTER TABLE ... ADD CHECK .. NOT VALID - Mailing list pgsql-hackers

From John Naylor
Subject Re: Reduce lock level for ALTER TABLE ... ADD CHECK .. NOT VALID
Date
Msg-id CAFBsxsH4=TT7zv3R4d7-JKrLymG6Ow8GaiwBvVcVsQG8YwJf0g@mail.gmail.com
Whole thread Raw
In response to Reduce lock level for ALTER TABLE ... ADD CHECK .. NOT VALID  (Simon Riggs <simon.riggs@enterprisedb.com>)
Responses Re: Reduce lock level for ALTER TABLE ... ADD CHECK .. NOT VALID  (Simon Riggs <simon.riggs@enterprisedb.com>)
List pgsql-hackers

On Thu, Apr 22, 2021 at 8:01 AM Simon Riggs <simon.riggs@enterprisedb.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

pgsql-hackers by date:

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