Thread: explicit-locking.html "key values" reference

explicit-locking.html "key values" reference

From
jian he
Date:


hi.
FOR KEY SHARE
Behaves similarly to FOR SHARE, except that the lock is weaker: SELECT FOR UPDATE is blocked, but not SELECT FOR NO KEY UPDATE. A key-shared lock blocks other transactions from performing DELETE or any UPDATE that changes the key values, but not other UPDATE, and neither does it prevent SELECT FOR NO KEY UPDATESELECT FOR SHARE, or SELECT FOR KEY SHARE.

A key-shared lock blocks other transactions from performing DELETE or any UPDATE that changes the key values

querya: select col1,col2,col3 from a for key share of a
Does "the key values" refer to these rows returned by the querya?
I still feel confused about "the key values". 

Re: explicit-locking.html "key values" reference

From
"David G. Johnston"
Date:
On Fri, May 26, 2023 at 8:02 PM jian he <jian.universality@gmail.com> wrote:

I still feel confused about "the key values". 

The "key" here is the Foreign Key relationship.  In short, FOR NO KEY UPDATE, promises that PK/FK values on the table will not be changed.  Only non-FK/PK columns can be changed.  In neither case may the row be removed either since that would necessitate changing the key to "non-existent".  However, the "UPDATE" part basically means "I am going to update some other column".  On the KEY SHARE side you basically get "I only care that this row/relationship continues to exist, you may change other attributes".

David J.