Re: Fix ALTER DOMAIN VALIDATE CONSTRAINT locking - Mailing list pgsql-hackers

From Chao Li
Subject Re: Fix ALTER DOMAIN VALIDATE CONSTRAINT locking
Date
Msg-id 3FB3A348-F15B-4D65-A747-0E747A18EB72@gmail.com
Whole thread
In response to Re: Fix ALTER DOMAIN VALIDATE CONSTRAINT locking  (Fujii Masao <masao.fujii@gmail.com>)
List pgsql-hackers

> On Jun 12, 2026, at 19:47, Fujii Masao <masao.fujii@gmail.com> wrote:
>
> On Mon, Jun 8, 2026 at 12:54 PM Chao Li <li.evan.chao@gmail.com> wrote:
>> See the attached patch for details. I also added an isolation test that follows the repro above.
>
> Thanks for the patch! It looks good to me.
>
> I just have a few minor review comments.
>
>
> * The lockmode is used for relations using the domain.  It should be
> * ShareLock when adding a new constraint to domain.  It can be
> * ShareUpdateExclusiveLock when validating an existing constraint.
>
> This comment in validateDomainCheckConstraint() still references
> ShareUpdateExclusiveLock, so it seems to need updating.
>
>
> Regarding the test, I think it would be safer to also check whether
> pg_constraint.convalidated is set correctly. For example:
>
> -----------------------
> step s3_validate       { ALTER DOMAIN alter_domain_validate_d VALIDATE
> CONSTRAINT alter_domain_validate_d_pos; }
> +step s3_validated      { SELECT convalidated FROM pg_constraint WHERE
> conname = 'alter_domain_validate_d_pos'; }
> step s3_check          { SELECT count(*) FROM alter_domain_validate_t; }
>
> -permutation s1_lock s2_insert s3_add s3_validate s1_unlock s3_check
> +permutation s1_lock s2_insert s3_add s3_validate s1_unlock s3_validated s3_chec
> -----------------------
>
>
> After the fix is committed, we should probably also ask Bruce to update
> the following v19 release note item?:
>
>    Reduce lock level of ALTER DOMAIN ... VALIDATE CONSTRAINT to match
> ALTER TABLE ... VALIDATE CONSTRAINT (Jian He) §
>
> Regards,
>
> --
> Fujii Masao

Hi Fujii-san,

Thanks for picking this up. PFA v2 that addressed your comments.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/





Attachment

pgsql-hackers by date:

Previous
From: Álvaro Herrera
Date:
Subject: Re: PSQL - prevent describe listing tables that are already in listed schemas
Next
From: Álvaro Herrera
Date:
Subject: Re: PSQL - prevent describe listing tables that are already in listed schemas