The lowest-level lock types are shared locks, followed by reserve locks, then update locks, and the highest-level lock types are exclusive locks.
Upgrades
Lock type upgrades are always attempted. If the duration of the upgrading lock is shorter, the upgrade of the lock type will be for that duration only.
Downgrades
Lock types are downgraded only when the duration of the new lock is greater than or equal to the duration of the existing lock. There are no lock type downgrades in transaction state. As lock type downgrades are delayed until after transaction state, only session locks survive after the end of a transaction for possible downgrading.
At the end of transaction state, all session locks are restored to the lock state to which they were last set manually, regardless of any lock type downgrade or upgrade done by transaction locks.
The following table lists lock upgrade and downgrade results.
Upgrading Type | Downgrading Type | Same Type | |
---|---|---|---|
Upgrading Duration |
Attempted |
Attempted at the end of transaction or load state |
Attempted |
Downgrading Duration |
Attempted for the upgrading lock type |
Ignored |
Ignored |
Same Duration |
Attempted |
Attempted at the end of transaction or load state |
Ignored |
The following table lists examples of results when upgrading locks.
Old Lock | New Lock | Upgrade Result | Comment |
---|---|---|---|
Transaction exclusive | Session exclusive | Session exclusive | Duration upgrade |
Transaction shared | Session exclusive | Session exclusive | Duration and type upgrades |
Transaction exclusive | Session shared | Session exclusive | Up to end of transaction, then automatically downgraded to session shared |
The following table lists examples of results when downgrading locks.
Old Lock | New Lock | Downgrade Result | Comment |
---|---|---|---|
Session shared | Transaction exclusive | Session exclusive | Up to end of transaction, then automatically downgraded to session shared |
Session exclusive | Transaction exclusive | Session exclusive | No duration downgrade |
Transaction exclusive | Transaction shared | Transaction shared | If not in transaction state |
Transaction exclusive | Transaction shared | Transaction exclusive | If in transaction state |
Transaction shared | Session shared | Session shared | Attempted |
Transaction shared | Session exclusive | Session exclusive | Attempted |