For example, SELECT ... LOCK IN SHARE MODE
sets an IS
lock and SELECT ... FOR UPDATE
sets an IX
lock.
The intention locking protocol is as follows:
-
Before a transaction can acquire an
S
lock on a row in tablet
, it must first acquire anIS
or stronger lock ont
. -
Before a transaction can acquire an
X
lock on a row, it must first acquire anIX
lock ont
.
These rules can be conveniently summarized by means of the following lock type compatibility matrix .
X | IX | S | IS | |
---|---|---|---|---|
X | Conflict | Conflict | Conflict | Conflict |
IX | Conflict | Compatible | Conflict | Compatible |
S | Conflict | Conflict | Compatible | Compatible |
IS | Conflict | Compatible | Compatible | Compatible |