public class RowLocking2 extends RowLockingRR
LockingPolicy| Modifier and Type | Field and Description |
|---|---|
private static LockingPolicy |
NO_LOCK |
lfMODE_CONTAINER, MODE_NONE, MODE_RECORD| Modifier | Constructor and Description |
|---|---|
protected |
RowLocking2(LockFactory lf) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
lockContainer(Transaction t,
ContainerHandle container,
boolean waitForLock,
boolean forUpdate)
Obtain container level intent lock.
|
boolean |
lockRecordForRead(Transaction t,
ContainerHandle container_handle,
RecordHandle record,
boolean waitForLock,
boolean forUpdate)
Obtain lock on record being read.
|
void |
unlockContainer(Transaction t,
ContainerHandle container_handle)
Unlock read locks.
|
void |
unlockRecordAfterRead(Transaction t,
ContainerHandle container_handle,
RecordHandle record,
boolean forUpdate,
boolean row_qualified)
Unlock a record after it has been locked for read.
|
getReadLockType, getUpdateLockType, getWriteLockTypegetMode, lockRecordForWrite, zeroDurationLockRecordForWriteprivate static final LockingPolicy NO_LOCK
protected RowLocking2(LockFactory lf)
public boolean lockContainer(Transaction t, ContainerHandle container, boolean waitForLock, boolean forUpdate) throws StandardException
This implementation of row locking is 2 level, ie. table and row locking. It will interact correctly with tables opened with ContainerLocking3 locking mode.
Updater's will get table level IX locks, and X row locks.
Reader's will get table level IS locks, and S row locks.
Read locks are put in a separate "group" from the transaction, so that when the container is closed it can release these read locks.
lockContainer in interface LockingPolicylockContainer in class RowLocking3t - Transaction to associate lock with.container - Container to lock.waitForLock - Should lock request wait until granted?forUpdate - Should container be locked for update, or read?StandardException - Standard exception policy.ContainerHandlepublic boolean lockRecordForRead(Transaction t, ContainerHandle container_handle, RecordHandle record, boolean waitForLock, boolean forUpdate) throws StandardException
Assumes that a table level IS has been acquired. Will acquire a Shared or Update lock on the row, depending on the "forUpdate" parameter.
Read lock will be placed on separate group from transaction.
lockRecordForRead in interface LockingPolicylockRecordForRead in class RowLocking3t - The transaction to associate the lock with.record - The record to be locked.waitForLock - Should lock request wait until granted?forUpdate - Whether to open for read or write access.container_handle - Open Container used to get record. Will be used
to row locks by the container they belong to.StandardException - Standard exception policy.Pagepublic void unlockRecordAfterRead(Transaction t, ContainerHandle container_handle, RecordHandle record, boolean forUpdate, boolean row_qualified) throws StandardException
RowLockingRRIn repeatable read only unlock records which "did not qualify". For example in a query like "select * from foo where a = 1" on a table with no index it is only necessary to hold locks on rows where a=1, but in the process of finding those rows the system will get locks on other rows to verify they are committed before applying the qualifier. Those locks can be released under repeatable read isolation.
unlockRecordAfterRead in interface LockingPolicyunlockRecordAfterRead in class RowLockingRRStandardException - Standard exception policy.Pagepublic void unlockContainer(Transaction t, ContainerHandle container_handle)
In Cursor stability release all read locks obtained. unlockContainer() will be called when the container is closed.
unlockContainer in interface LockingPolicyunlockContainer in class NoLockingt - The transaction to associate the lock with.container_handle - Container to unlock.ContainerHandle,
ContainerHandle.close()Apache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.