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 bp...@apache.org on 2006/06/25 19:15:31 UTC

svn commit: r417032 - in /db/derby/code/branches/10.1/java: drda/org/apache/derby/impl/drda/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/ testing/org/apache/derbyTesting/func...

Author: bpendleton
Date: Sun Jun 25 10:15:31 2006
New Revision: 417032

URL: http://svn.apache.org/viewvc?rev=417032&view=rev
Log:
DERBY-1454: DRDA Protocol Exception when DSS is exactly 32767 bytes

Merged trunk revision 416959 to 10.1 branch.

The server is disconnecting the client connection. Client is sending a CNTQRY,
the server is receiving it and then server disconnects the client. In doneData
and writeFDODTA, it looks like if (writer.getDSSLength() >= blksize) ,
then the splitQRYDTA is called. From testing, it seems like they are hitting
an edge case, where the writer.getDSSLength() is equal to blksize and this
DSS is the only dss in the send buffer. 

The patch corrects the two splitQRYDTA calls to use > rather
than >= to determine if the DSS needs to be split.

The patch also contains a new test case in derbynet/prepStmt.java
to demonstrate the bug and its fix.


Modified:
    db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java

Modified: db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=417032&r1=417031&r2=417032&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Sun Jun 25 10:15:31 2006
@@ -6169,7 +6169,7 @@
 				}
 			}
 			// does all this fit in one QRYDTA
-			if (writer.getDSSLength() >= blksize)
+			if (writer.getDSSLength() > blksize)
 			{
 				splitQRYDTA(stmt, blksize);
 				return false;
@@ -6334,7 +6334,7 @@
 
 		writer.writeByte(CodePoint.NULLDATA);
 		// does all this fit in one QRYDTA
-		if (writer.getDSSLength() >= blksize)
+		if (writer.getDSSLength() > blksize)
 		{
 			splitQRYDTA(stmt, blksize);
 		}

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out?rev=417032&r1=417031&r2=417032&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out Sun Jun 25 10:15:31 2006
@@ -79,4 +79,10 @@
 Jira170: caught expected table not found
 Iteration 1 successful: 555 parameter markers successfully prepared and executed.
 Test jira125 successful: 557 parameter markers successfully prepared and executed.
+JIRA-1454 repro with c2 len=12748
+Fetched a row, c2.length=12748
+JIRA-1454 repro with c2 len=12750
+Fetched a row, c2.length=12750
+JIRA-1454 repro with c2 len=12749
+Fetched a row, c2.length=12749
 prepStmt Test Ends

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out?rev=417032&r1=417031&r2=417032&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out Sun Jun 25 10:15:31 2006
@@ -79,4 +79,10 @@
 Jira170: caught expected table not found
 Iteration 1 successful: 555 parameter markers successfully prepared and executed.
 Test jira125 successful: 557 parameter markers successfully prepared and executed.
+JIRA-1454 repro with c2 len=12748
+Fetched a row, c2.length=12748
+JIRA-1454 repro with c2 len=12750
+Fetched a row, c2.length=12750
+JIRA-1454 repro with c2 len=12749
+Fetched a row, c2.length=12749
 prepStmt Test Ends

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out?rev=417032&r1=417031&r2=417032&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out Sun Jun 25 10:15:31 2006
@@ -79,4 +79,10 @@
 Jira170: caught expected table not found
 Iteration 1 successful: 555 parameter markers successfully prepared and executed.
 Test jira125 successful: 557 parameter markers successfully prepared and executed.
+JIRA-1454 repro with c2 len=12748
+Fetched a row, c2.length=12748
+JIRA-1454 repro with c2 len=12750
+Fetched a row, c2.length=12750
+JIRA-1454 repro with c2 len=12749
+Fetched a row, c2.length=12749
 prepStmt Test Ends

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java?rev=417032&r1=417031&r2=417032&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java Sun Jun 25 10:15:31 2006
@@ -305,6 +305,7 @@
 			jira614Test_a(conn);
 			jira170Test(conn);
 			jira125Test(conn);
+			jira1454Test(conn);
 			conn.close();
 			System.out.println("prepStmt Test Ends");
         }
@@ -819,6 +820,59 @@
                 e.printStackTrace();
         }
     }
+	/**
+	  * Jira-1454 is an off-by-one bug in the splitQRYDTA processing in the
+	  * Network Server writeQRYDTA code, and is related to previous bugs
+	  * 614, 170, 491, and 492. The issue is that if the DSS block is exactly
+	  * the maximum DSS length (32767), then the writeQRYDTA code erroneously
+	  * thinks the DSS needs to be split when in fact it doesn't.
+	  *
+	  * The repro case sets up the boundary scenario; we run the case three
+	  * times, once with the value 1 less than the max DSS, once with the
+	  * value 1 greater than the max DSS, and once with the exact DSS length.
+	  * Only the third case triggers the JIRA-1454 bug; the other two tests
+	  * are for completeness.
+	  */
+	private static void jira1454Test(Connection conn)
+		throws Exception
+	{
+		tickleDSSLength(conn, 12748);
+		tickleDSSLength(conn, 12750);
+		tickleDSSLength(conn, 12749);
+	}
+	private static void tickleDSSLength(Connection conn, int c2Len)
+		throws Exception
+	{
+		System.out.println("JIRA-1454 repro with c2 len=" + c2Len);
+		Statement st = conn.createStatement();
+
+		try {
+			    st.execute("drop table jira1454");
+		} catch (SQLException se) {}
+		st.execute(
+				"create table jira1454(c1 varchar(20000),c2 varchar(30000))");
+
+		char [] c1 = new char[20000];
+		for (int i = 0; i < c1.length; i++)
+			    c1[i] = Character.forDigit(i%10, 10);
+		char [] c2 = new char[30000];
+		for (int i = 0; i < c2Len; i++)
+			    c2[i] = Character.forDigit(i%10, 10);
+
+		PreparedStatement pSt =
+			conn.prepareStatement("insert into jira1454 values (?,?)");
+		pSt.setString(1, new String(c1));
+		pSt.setString(2, new String(c2,0, c2Len));
+
+		pSt.execute();
+		pSt.close();
+		ResultSet rs = st.executeQuery("select * from jira1454");
+		while (rs.next())
+			    System.out.println("Fetched a row, c2.length=" +
+						            rs.getString("c2").length());
+		rs.close();
+		st.close();
+	}
 	/**
 	 * Jira-125 has to do with proper use of continuation headers 
 	 * for very large reply messages, such as the SQLDARD which is