--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.store.access.btree.index.B2IRowLocking1\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.store.access.btree.index;\r
+\r
+import org.apache.derby.iapi.error.StandardException; \r
+\r
+import org.apache.derby.iapi.store.access.ConglomerateController;\r
+import org.apache.derby.iapi.types.RowLocation;\r
+\r
+import org.apache.derby.iapi.store.raw.FetchDescriptor;\r
+import org.apache.derby.iapi.store.raw.LockingPolicy;\r
+import org.apache.derby.iapi.store.raw.Transaction;\r
+\r
+import org.apache.derby.iapi.types.DataValueDescriptor;\r
+\r
+import org.apache.derby.impl.store.access.btree.BTree;\r
+import org.apache.derby.impl.store.access.btree.BTreeLockingPolicy;\r
+import org.apache.derby.impl.store.access.btree.BTreeRowPosition;\r
+import org.apache.derby.impl.store.access.btree.OpenBTree;\r
+\r
+/**\r
+\r
+The btree locking policy which implements read uncommitted isolation level.\r
+\r
+It inherits all functionality from B2IRowLocking2 except that it does not\r
+get any read row locks (and thus does not release them). Note that table\r
+level and table level intent locking remains the same as B2IRowLocking2 as\r
+this is currently the way we prevent concurrent ddl from happening while a\r
+read uncommitted scanner is operating in the btree.\r
+\r
+**/\r
+\r
+class B2IRowLocking1 extends B2IRowLocking2 implements BTreeLockingPolicy\r
+{ \r
+ /**************************************************************************\r
+ * Fields of the class\r
+ **************************************************************************\r
+ */\r
+\r
+ /**************************************************************************\r
+ * Constructors for This class:\r
+ **************************************************************************\r
+ */\r
+ B2IRowLocking1(\r
+ Transaction rawtran,\r
+ int lock_level,\r
+ LockingPolicy locking_policy,\r
+ ConglomerateController base_cc,\r
+ OpenBTree open_btree)\r
+ {\r
+ super(rawtran, lock_level, locking_policy, base_cc, open_btree);\r
+ }\r
+\r
+\r
+ /**************************************************************************\r
+ * Public Methods of This class:\r
+ **************************************************************************\r
+ */\r
+\r
+\r
+ /**************************************************************************\r
+ * Abstract Protected lockScan*() locking methods of BTree:\r
+ * lockScan - lock the scan page\r
+ * (inherit from B2IRowLocking2, we still\r
+ * get page control locks).\r
+ * lockScanForReclaimSpace - lock page for reclaiming deleted rows.\r
+ * (inherit from B2IRowLocking2, should never\r
+ * be called while in read uncommitted).\r
+ * lockScanRow - lock row and possibly the scan page, only\r
+ * if row is forUpdate and not a previous key\r
+ * lock.\r
+ * unlockScan - unlock the scan page\r
+ * (inherit from B2IRowLocking2, should never\r
+ * be called while in read uncommitted).\r
+ * unlockScanRecordAfterRead- unlock the scan record if we locked it in\r
+ * lockScanRow.\r
+ * \r
+ **************************************************************************\r
+ */\r
+\r
+\r
+\r
+ /**\r
+ * Lock a row as part of doing the scan.\r
+ * <p>\r
+ * Lock the row at the given slot (or the previous row if slot is 0).\r
+ * Get the scan lock on the page if "request_scan_lock" is true.\r
+ * <p>\r
+ * If this routine returns true all locks were acquired while maintaining\r
+ * the latch on leaf. If this routine returns false, locks may or may\r
+ * not have been acquired, and the routine should be called again after\r
+ * the client has researched the tree to reget the latch on the \r
+ * appropriate page.\r
+ * (p>\r
+ * As a side effect stores the value of the record handle of the current\r
+ * scan lock.\r
+ *\r
+ * @return Whether locks were acquired without releasing latch on leaf.\r
+ *\r
+ * @param open_btree The open_btree to associate latches with - \r
+ * used if routine has to scan backward.\r
+ * @param btree the conglomerate info.\r
+ * @param pos The position of the row to lock.\r
+ * @param request_scan_lock Whether to request the page scan lock, should\r
+ * only be requested once per page in the scan.\r
+ * @param lock_template A scratch area to use to read in rows.\r
+ * @param previous_key_lock Is this a previous key lock call?\r
+ * @param forUpdate Is the scan for update or for read only.\r
+ *\r
+ * @exception StandardException Standard exception policy.\r
+ **/\r
+ public boolean lockScanRow(\r
+ OpenBTree open_btree,\r
+ BTree btree,\r
+ BTreeRowPosition pos,\r
+ boolean request_scan_lock,\r
+ FetchDescriptor lock_fetch_desc,\r
+ DataValueDescriptor[] lock_template,\r
+ RowLocation lock_row_loc,\r
+ boolean previous_key_lock,\r
+ boolean forUpdate,\r
+ int lock_operation)\r
+ throws StandardException\r
+ {\r
+ // request the scan lock if necessary.\r
+ // only get the row lock if it is not a previous key lock and iff\r
+ // it is an update lock.\r
+ return(\r
+ _lockScanRow(\r
+ open_btree,\r
+ btree,\r
+ pos,\r
+ (forUpdate && !previous_key_lock), // only get update row lock\r
+ request_scan_lock,\r
+ lock_fetch_desc, lock_template, lock_row_loc,\r
+ previous_key_lock,\r
+ forUpdate,\r
+ lock_operation));\r
+ }\r
+\r
+ /**\r
+ * Release read lock on a row.\r
+ *\r
+ * Because this is read uncommitted no S row locks will have been requested,\r
+ * thus none need be released. The only locks that need to be released\r
+ * are U locks requested if the scan was opened for update.\r
+ *\r
+ * @param pos The position of the row to unlock.\r
+ * @param forUpdate Is the scan for update or for read only.\r
+ *\r
+ **/\r
+ public void unlockScanRecordAfterRead(\r
+ BTreeRowPosition pos,\r
+ boolean forUpdate)\r
+ throws StandardException\r
+ {\r
+ if (forUpdate)\r
+ {\r
+ super.unlockScanRecordAfterRead(pos, forUpdate);\r
+ }\r
+ }\r
+\r
+ /**************************************************************************\r
+ * Abstract Protected lockNonScan*() locking methods of BTree:\r
+ *\r
+ * lockNonScanPreviousRow - lock the row previous to the current\r
+ * (inherit from B2IRowLocking2, we still \r
+ * get page control locks) - only called\r
+ * by insert.\r
+ * lockNonScanRow - lock the input row\r
+ * (inherit from B2IRowLocking2, we still\r
+ * get page control locks) - only called\r
+ * by insert.\r
+ **************************************************************************\r
+ */\r
+\r
+}\r