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 km...@apache.org on 2008/02/05 17:12:47 UTC

svn commit: r618684 - in /db/derby/code/branches/10.3/java: client/org/apache/derby/client/net/NetCursor.java engine/org/apache/derby/impl/jdbc/EmbedConnection.java

Author: kmarsden
Date: Tue Feb  5 08:12:39 2008
New Revision: 618684

URL: http://svn.apache.org/viewvc?rev=618684&view=rev
Log:
DERBY-3243 (jdbc net client) exception during normal iteration through "ResultSet" of "select * from t"

port revision 618431 from trunk


Modified:
    db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetCursor.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java

Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetCursor.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetCursor.java?rev=618684&r1=618683&r2=618684&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetCursor.java (original)
+++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetCursor.java Tue Feb  5 08:12:39 2008
@@ -1061,9 +1061,12 @@
     private int locator(int column)
     {
         int locator = get_INTEGER(column);
-        // If Lob value was sent instead of locator, highest bit will be set
+        // If Lob value was sent instead of locator, the value will be
+        // 0x8000, 0x8002, 0x8004, 0x8006, 0x8008. This is not a locator 
+        // but the blob has been sent by value.
         // Zero is not a valid locator, it indicates a zero length value
-        if (((locator & 0x8000) == 0x8000) || (locator == 0)) {
+        if ((locator == 0x8000) || (locator == 0x8002) || (locator == 0x8004) || 
+                (locator == 0x8006) || (locator == 0x8008) ||(locator == 0)) {
             return Lob.INVALID_LOCATOR;
         } else {
             return locator;

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?rev=618684&r1=618683&r2=618684&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java (original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java Tue Feb  5 08:12:39 2008
@@ -2376,11 +2376,31 @@
 	}
 
 	/**
-	* Return the current locator value
+	* Return the current locator value/
+        * 0x800x values are not  valid values as they are used to indicate the BLOB 
+        * is being sent by value, so we skip those values (DERBY-3243)
+        * 
 	* @return an integer that represents the most recent locator value.
 	*/
 	private int getIncLOBKey() {
-		return ++rootConnection.lobHMKey;
+                int newKey = ++rootConnection.lobHMKey;
+                // Skip 0x8000, 0x8002, 0x8004, 0x8006, for DERBY-3243
+                // Earlier versions of the Derby Network Server (<10.3) didn't
+                // support locators and would send an extended length field
+                // with one of the above mentioned values instead of a
+                // locator, even when locators were requested. To enable the
+                // client driver to detect that locators aren't supported,
+                // we don't use any of them as locator values.
+                if (newKey == 0x8000 || newKey == 0x8002 ||  newKey == 0x8004 ||
+                     newKey == 0x8006 || newKey == 0x8008)
+                    newKey = ++rootConnection.lobHMKey;
+                // Also roll over when the high bit of four byte locator is set.
+                // This will prevent us from sending a negative locator to the
+                // client. Don't allow zero since it is not a valid locator for the 
+                // client.
+                if (newKey == 0x80000000 || newKey == 0)
+                    newKey = rootConnection.lobHMKey = 1;
+                return newKey;
 	}
 
 	/**