Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 38847 invoked from network); 8 Jun 2010 09:24:56 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Jun 2010 09:24:56 -0000 Received: (qmail 99841 invoked by uid 500); 8 Jun 2010 09:24:56 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 99777 invoked by uid 500); 8 Jun 2010 09:24:55 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 99770 invoked by uid 99); 8 Jun 2010 09:24:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jun 2010 09:24:54 +0000 X-ASF-Spam-Status: No, hits=-1591.4 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jun 2010 09:24:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CB25D23889DD; Tue, 8 Jun 2010 09:24:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r952585 - in /db/derby/code/branches/10.6: ./ java/engine/org/apache/derby/impl/store/access/conglomerate/ java/testing/org/apache/derbyTesting/functionTests/tests/store/ Date: Tue, 08 Jun 2010 09:24:33 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100608092433.CB25D23889DD@eris.apache.org> Author: kahatlen Date: Tue Jun 8 09:24:33 2010 New Revision: 952585 URL: http://svn.apache.org/viewvc?rev=952585&view=rev Log: DERBY-4676: NullPointerException on SELECT on INNER JOIN Merged fix from trunk (revision 952138). Added: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby4676Test.java - copied unchanged from r952138, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby4676Test.java Modified: db/derby/code/branches/10.6/ (props changed) db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerateController.java db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerate.java db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java Propchange: db/derby/code/branches/10.6/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jun 8 09:24:33 2010 @@ -1 +1 @@ -/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,944152,946794,948045,948069 +/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,944152,946794,948045,948069,952138 Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerateController.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerateController.java?rev=952585&r1=952584&r2=952585&view=diff ============================================================================== --- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerateController.java (original) +++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerateController.java Tue Jun 8 09:24:33 2010 @@ -284,6 +284,14 @@ public abstract class GenericConglomerat pos, (RowPosition) null, false, true); } + if (pos.current_page == null) + { + // The page is not latched after locking the row. This happens if + // the row was deleted while we were waiting for the lock. Return + // false to indicate that the row is no longer valid. (DERBY-4676) + return false; + } + // Fetch the row. // RESOLVE (STO061) - don't know whether the fetch is for update or not. // @@ -381,6 +389,14 @@ public abstract class GenericConglomerat pos, (RowPosition) null, false, waitForLock); } + if (pos.current_page == null) + { + // The page is not latched after locking the row. This happens if + // the row was deleted while we were waiting for the lock. Return + // false to indicate that the row is no longer valid. (DERBY-4676) + return false; + } + // Fetch the row. // RESOLVE (STO061) - don't know whether the fetch is for update or not. // Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerate.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerate.java?rev=952585&r1=952584&r2=952585&view=diff ============================================================================== --- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerate.java (original) +++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/store/access/conglomerate/OpenConglomerate.java Tue Jun 8 09:24:33 2010 @@ -276,11 +276,25 @@ public abstract class OpenConglomerate } /** + *

* Latch the page containing the current RowPosition. + *

+ * *

* This implementation also automatically updates the RowPosition to * point at the slot containing the current RowPosition. This slot * value is only valid while the latch is held. + *

+ * + *

+ * If the row pointed to by {@code pos} does not exist (including the + * case where the page itself does not exist), the page will not be + * latched, and {@code pos.current_page} will be set to {@code null}. + *

+ * + * @param pos the position to a row on the page that should be latched + * @return {@code true} if the page was successfully latched, or + * {@code false} otherwise * * @exception StandardException Standard exception policy. **/ @@ -329,13 +343,18 @@ public abstract class OpenConglomerate /** + *

* Lock row at given row position for read. + *

+ * *

* This routine requests a row lock NOWAIT on the row located at the given * RowPosition. If the lock is granted NOWAIT the * routine will return true. If the lock cannot be granted NOWAIT, then * the routine will release the latch on "page" and then it will request * a WAIT lock on the row. + *

+ * *

* This implementation: * Assumes latch held on current_page. @@ -344,11 +363,22 @@ public abstract class OpenConglomerate * If the current_rh field of RowPosition is null, it is assumed the we * want to lock the indicated current_slot. Upon return current_rh will * point to the record handle associated with current_slot. + *

+ * *

* After waiting and getting the lock on the row, this routine will fix up * RowPosition to point at the row locked. This means it will get the * page latch again, and it will fix the current_slot to point at the * waited for record handle - it may have moved while waiting on the lock. + *

+ * + *

+ * When this method returns, the page holding the row pointed to by the + * {@code RowLocation} is latched. This is however not the case if + * {@code moveForwardIfRowDisappears} is {@code false} and the row has + * disappeared. Then the latch will be released before the method returns, + * and {@code pos.current_page} will be set to {@code null}. + *

* * @param pos Position to lock. * @param aux_pos If you have to give up latch to get lock, then also @@ -356,8 +386,8 @@ public abstract class OpenConglomerate * @param moveForwardIfRowDisappears * If true, then this routine must handle the case where * the row id we are waiting on disappears when the latch - * is released. If false an exception will be thrown if - * the row disappears. + * is released. If false, and the row disappears, the + * latch will be released again and false is returned. * @param waitForLock * if true wait for lock, if lock can't be granted NOWAIT, * else if false, throw a lock timeout exception if the @@ -470,6 +500,25 @@ public abstract class OpenConglomerate return(lock_granted_with_latch_held); } + /** + *

+ * Lock the row at the given position for write. + *

+ * + *

+ * The page pointed to by the {@code RowPosition} is assumed to be latched + * when this method is called. If the lock cannot be obtained without + * waiting, the latch will be released and re-obtained when the lock has + * been acquired. + *

+ * + *

+ * If the latch was released while waiting for the lock, and the row does + * not exist after the lock is obtained, the latch will be released again + * before the method returns, and {@code pos.current_page} will be set to + * {@code null}. + *

+ */ public boolean lockPositionForWrite( RowPosition pos, boolean forInsert, Modified: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java?rev=952585&r1=952584&r2=952585&view=diff ============================================================================== --- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java (original) +++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/store/_Suite.java Tue Jun 8 09:24:33 2010 @@ -57,6 +57,7 @@ public class _Suite extends BaseTestCase suite.addTest(StreamingColumnTest.suite()); suite.addTest(Derby3625Test.suite()); suite.addTest(Derby151Test.suite()); + suite.addTest(Derby4676Test.suite()); suite.addTest(PositionedStoreStreamTest.suite()); suite.addTest(OSReadOnlyTest.suite()); suite.addTest(BackupRestoreTest.suite());