You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by be...@apache.org on 2006/05/23 23:48:15 UTC

svn commit: r409009 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java

Author: bernt
Date: Tue May 23 14:48:14 2006
New Revision: 409009

URL: http://svn.apache.org/viewvc?rev=409009&view=rev
Log:
DERBY-1276 Calling ResultSet.isLast() on a scrollable insensitive resultset, causes the entire ResultSet to be populated. Submitted by Andreas Korneliussen

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java?rev=409009&r1=409008&r2=409009&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java Tue May 23 14:48:14 2006
@@ -739,31 +739,24 @@
 		case ISFIRST:
 			return (currentPosition == 1);
 		case ISLAST:
-			if (beforeFirst || afterLast)
+			if (beforeFirst || afterLast || currentPosition==0 ||
+				currentPosition<positionInSource)
 			{
 				return false;
-			}
-
-			/* If we've already seen the last row
-			 * then we can tell if we are on it by
-			 * the current position,
-			 * otherwise, we need to find the last
-			 * row in order to tell if the current row
-			 * is the last row.
+			}			
+			
+			/* If we have seen the last row, we can tell if we are 
+			 * on it by comparing currentPosition with lastPosition.
+			 * Otherwise, we check if there is a next row.
 			 */
 			if (seenLast)
 			{
-				return (currentPosition == lastPosition && currentPosition != 0);
+				return (currentPosition == lastPosition);
 			}
 			else
 			{
-				int savePosition = currentPosition;
-				boolean retval = false;
-				getLastRow();
-				if (savePosition == lastPosition && savePosition != 0)
-				{
-					retval = true;
-				}
+				final int savePosition = currentPosition;
+				final boolean retval = (getNextRowFromSource() == null);
 				getRowFromHashTable(savePosition);
 				return retval;
 			}