Re: Why need a lock?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jacktby jacktby <jacktby(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Why need a lock?
Date: 2023-09-25 15:33:43
Message-ID: 19380.1695656023@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

jacktby jacktby <jacktby(at)gmail(dot)com> writes:
> I find this in source code
> #define ShareLock 5 /* CREATE INDEX (WITHOUT CONCURRENTLY) */
> I think if there is no CONCURRENTLY, so why we need a lock, I think that’s unnecessary. What’s the point?

We need a lock precisely to prevent concurrent execution
(of table modifications that would confuse the index build).

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2023-09-25 16:00:39 Re: CREATE FUNCTION ... SEARCH { DEFAULT | SYSTEM | SESSION }
Previous Message Robert Haas 2023-09-25 15:30:07 Re: CREATE FUNCTION ... SEARCH { DEFAULT | SYSTEM | SESSION }