Why need a lock?

Started by jacktby jacktbyover 2 years ago2 messages
#1jacktby jacktby
jacktby@gmail.com

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?

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: jacktby jacktby (#1)
Re: Why need a lock?

jacktby jacktby <jacktby@gmail.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