db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpendle...@apache.org
Subject svn commit: r416959 - in /db/derby/code/trunk/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/functionTest...
Date Sat, 24 Jun 2006 20:54:59 GMT
Author: bpendleton
Date: Sat Jun 24 13:54:59 2006
New Revision: 416959

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

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/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=416959&r1=416958&r2=416959&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Sat Jun 24
13:54:59 2006
@@ -6408,7 +6408,7 @@
 				}
 			}
 			// does all this fit in one QRYDTA
-			if (writer.getDSSLength() >= blksize)
+			if (writer.getDSSLength() > blksize)
 			{
 				splitQRYDTA(stmt, blksize);
 				return false;
@@ -6588,7 +6588,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/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out?rev=416959&r1=416958&r2=416959&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/jdk15/prepStmt.out
Sat Jun 24 13:54:59 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/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out?rev=416959&r1=416958&r2=416959&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk15/prepStmt.out
Sat Jun 24 13:54:59 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/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out?rev=416959&r1=416958&r2=416959&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmt.out
Sat Jun 24 13:54:59 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/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java?rev=416959&r1=416958&r2=416959&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/prepStmt.java
Sat Jun 24 13:54:59 2006
@@ -316,6 +316,7 @@
 			jira170Test(conn);
 			jira125Test(conn);
 			jira428Test(conn);
+			jira1454Test(conn);
 			conn.close();
 			// refresh conn before cleaning up
 			conn = ij.startJBMS();
@@ -833,6 +834,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



Mime
View raw message