org.apache.derby.impl.store.raw.xact
Class RowLocking1

java.lang.Object
  extended byorg.apache.derby.impl.store.raw.xact.NoLocking
      extended byorg.apache.derby.impl.store.raw.xact.RowLocking3
          extended byorg.apache.derby.impl.store.raw.xact.RowLockingRR
              extended byorg.apache.derby.impl.store.raw.xact.RowLocking2
                  extended byorg.apache.derby.impl.store.raw.xact.RowLocking1
All Implemented Interfaces:
LockingPolicy

public class RowLocking1
extends RowLocking2

A locking policy that implements row level locking with isolation degree 1. This is an implementation of Gray's degree 1 isolation, read uncommitted, or often referred to as dirty reads. Basically read operations are done with no locking. This locking policy is only to be used for read operations. The approach is to place all "write" container and row locks on the transaction group lock list. Locks on this group will last until end of transaction. This implementation will still get table level intent locks. This is to prevent hard cases where the container otherwise could be deleted while read uncommitted reader is still accessing it. In order to not get table level intent locks some sort of other ddl level lock would have to be implemented. All "read" row locks will be not be requested. Note that write operations extend from the RowLocking3 implementations.

See Also:
LockingPolicy

Field Summary
 
Fields inherited from class org.apache.derby.impl.store.raw.xact.RowLocking2
 
Fields inherited from class org.apache.derby.impl.store.raw.xact.RowLocking3
lf
 
Fields inherited from interface org.apache.derby.iapi.store.raw.LockingPolicy
MODE_CONTAINER, MODE_NONE, MODE_RECORD
 
Constructor Summary
protected RowLocking1(LockFactory lf)
           
 
Method Summary
 void lockRecordForRead(Latch latch, RecordHandle record, boolean forUpdate)
          Obtain lock on record being read while holding a latch.
 boolean lockRecordForRead(Transaction t, ContainerHandle container_handle, RecordHandle record, boolean waitForLock, boolean forUpdate)
          Obtain lock on record being read.
 void unlockRecordAfterRead(Transaction t, ContainerHandle container_handle, RecordHandle record, boolean forUpdate, boolean row_qualified)
          Unlock a record after it has been locked for read.
 
Methods inherited from class org.apache.derby.impl.store.raw.xact.RowLocking2
lockContainer, unlockContainer
 
Methods inherited from class org.apache.derby.impl.store.raw.xact.RowLockingRR
getReadLockType, getUpdateLockType, getWriteLockType
 
Methods inherited from class org.apache.derby.impl.store.raw.xact.RowLocking3
getMode, lockRecordForWrite, lockRecordForWrite, zeroDurationLockRecordForWrite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowLocking1

protected RowLocking1(LockFactory lf)
Method Detail

lockRecordForRead

public boolean lockRecordForRead(Transaction t,
                                 ContainerHandle container_handle,
                                 RecordHandle record,
                                 boolean waitForLock,
                                 boolean forUpdate)
                          throws StandardException
Obtain lock on record being read.

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.

Specified by:
lockRecordForRead in interface LockingPolicy
Overrides:
lockRecordForRead in class RowLocking2
Parameters:
t - 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.
Returns:
true if the lock was granted, false if waitForLock was false and the lock could not be granted.
Throws:
StandardException - Standard exception policy.

lockRecordForRead

public void lockRecordForRead(Latch latch,
                              RecordHandle record,
                              boolean forUpdate)
                       throws StandardException
Obtain lock on record being read while holding a latch.

Assumes that a table level IS has been acquired. Will acquire a Shared or Update lock on the row, depending on the "forUpdate" parameter.

Specified by:
lockRecordForRead in interface LockingPolicy
Overrides:
lockRecordForRead in class RowLocking2
Parameters:
latch - The latch being held.
record - The record to be locked.
forUpdate - Whether to open for read or write access.
Throws:
StandardException - Standard exception policy.

unlockRecordAfterRead

public void unlockRecordAfterRead(Transaction t,
                                  ContainerHandle container_handle,
                                  RecordHandle record,
                                  boolean forUpdate,
                                  boolean row_qualified)
                           throws StandardException
Description copied from class: RowLockingRR
Unlock a record after it has been locked for read.

In 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.

Specified by:
unlockRecordAfterRead in interface LockingPolicy
Overrides:
unlockRecordAfterRead in class RowLocking2
Throws:
StandardException

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.