001: /*
002:
003: Derby - Class org.apache.derby.impl.store.access.btree.index.B2IRowLocking2
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.store.access.btree.index;
023:
024: import org.apache.derby.iapi.services.sanity.SanityManager;
025:
026: import org.apache.derby.iapi.error.StandardException;
027:
028: import org.apache.derby.iapi.store.access.conglomerate.TransactionManager;
029:
030: import org.apache.derby.iapi.store.access.ConglomerateController;
031: import org.apache.derby.iapi.types.RowLocation;
032: import org.apache.derby.iapi.store.access.TransactionController;
033:
034: import org.apache.derby.iapi.store.raw.LockingPolicy;
035: import org.apache.derby.iapi.store.raw.Page;
036: import org.apache.derby.iapi.store.raw.RecordHandle;
037: import org.apache.derby.iapi.store.raw.Transaction;
038:
039: import org.apache.derby.iapi.types.DataValueDescriptor;
040:
041: import org.apache.derby.impl.store.access.btree.BTree;
042: import org.apache.derby.impl.store.access.btree.BTreeLockingPolicy;
043: import org.apache.derby.impl.store.access.btree.BTreeRowPosition;
044: import org.apache.derby.impl.store.access.btree.ControlRow;
045: import org.apache.derby.impl.store.access.btree.LeafControlRow;
046: import org.apache.derby.impl.store.access.btree.OpenBTree;
047: import org.apache.derby.impl.store.access.btree.WaitError;
048:
049: /**
050:
051: The btree locking policy which implements read committed isolation level.
052:
053: It inherits all functionality from B2IRowLockingRR (repeatable read) except
054: that it releases read locks after obtaining them. It provides a single
055: implementation of unlockScanRecordAfterRead() which releases a read lock
056: after it has been locked and processed.
057:
058: **/
059:
060: class B2IRowLocking2 extends B2IRowLockingRR implements
061: BTreeLockingPolicy {
062:
063: /**************************************************************************
064: * Constructors for This class:
065: **************************************************************************
066: */
067: B2IRowLocking2(Transaction rawtran, int lock_level,
068: LockingPolicy locking_policy,
069: ConglomerateController base_cc, OpenBTree open_btree) {
070: super (rawtran, lock_level, locking_policy, base_cc, open_btree);
071: }
072:
073: /**************************************************************************
074: * Public Methods of This class:
075: **************************************************************************
076: */
077:
078: /**
079: * Release read lock on a row.
080: *
081: * @param forUpdate Is the scan for update or for read only.
082: *
083: **/
084: public void unlockScanRecordAfterRead(BTreeRowPosition pos,
085: boolean forUpdate) throws StandardException {
086: if (SanityManager.DEBUG) {
087: SanityManager.ASSERT(open_btree != null,
088: "open_btree is null");
089:
090: SanityManager.ASSERT(pos.current_leaf != null,
091: "leaf is null");
092:
093: SanityManager.ASSERT(pos.current_lock_row_loc != null,
094: "pos.current_lock_row_loc is null");
095:
096: SanityManager.ASSERT(!pos.current_lock_row_loc.isNull(),
097: "pos.current_lock_row_loc isNull()");
098: }
099:
100: // always unlock in read committed, so pass false for qualified arg.
101: base_cc.unlockRowAfterRead(pos.current_lock_row_loc, forUpdate,
102: false);
103: }
104: }
|