Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 70968 invoked from network); 24 Jun 2006 20:55:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Jun 2006 20:55:22 -0000 Received: (qmail 58530 invoked by uid 500); 24 Jun 2006 20:55:22 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 58500 invoked by uid 500); 24 Jun 2006 20:55:21 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 58489 invoked by uid 99); 24 Jun 2006 20:55:21 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Jun 2006 13:55:21 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Jun 2006 13:55:20 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id D09061A9842; Sat, 24 Jun 2006 13:55:00 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: derby-commits@db.apache.org From: bpendleton@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060624205500.D09061A9842@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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