db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
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 GMT
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
     }
 
     /**
+     * <p>
      * Latch the page containing the current RowPosition.
+     * </p>
+     *
      * <p>
      * 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.
+     * </p>
+     *
+     * <p>
+     * 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}.
+     * </p>
+     *
+     * @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
 
 
     /**
+     * <p>
      * Lock row at given row position for read.
+     * </p>
+     *
      * <p>
      * 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.  
+     * </p>
+     *
      * <p>
      * 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.
+     * </p>
+     *
      * <p>
      * 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.
+     * </p>
+     *
+     * <p>
+     * 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}.
+     * </p>
      *
      * @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);
     }
 
+    /**
+     * <p>
+     * Lock the row at the given position for write.
+     * </p>
+     *
+     * <p>
+     * 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.
+     * </p>
+     *
+     * <p>
+     * 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}.
+     * </p>
+     */
     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());



Mime
View raw message