Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 65700 invoked from network); 3 May 2007 19:29:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 May 2007 19:29:55 -0000 Received: (qmail 75795 invoked by uid 500); 3 May 2007 19:29:57 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 75715 invoked by uid 500); 3 May 2007 19:29:57 -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 75669 invoked by uid 99); 3 May 2007 19:29:56 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 May 2007 12:29:56 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 May 2007 12:29:47 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 084471A9838; Thu, 3 May 2007 12:29:27 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r534969 - 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... Date: Thu, 03 May 2007 19:29:26 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070503192927.084471A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kmarsden Date: Thu May 3 12:29:25 2007 New Revision: 534969 URL: http://svn.apache.org/viewvc?view=rev&rev=534969 Log: DERBY-1533 ArrayIndexOutOfBoundsException in DDMReader, on a specific data size Modified: db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DDMReader.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/DDMReader.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DDMReader.java?view=diff&rev=534969&r1=534968&r2=534969 ============================================================================== --- db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DDMReader.java (original) +++ db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/DDMReader.java Thu May 3 12:29:25 2007 @@ -1335,7 +1335,7 @@ { byte[] b; - if (length < dssLength) + if (length < DssConstants.MAX_DSS_LENGTH) { ensureBLayerDataInBuffer (length, ADJUST_LENGTHS); b = new byte[length]; @@ -1609,22 +1609,21 @@ DRDAProtocolException.NO_CODPNT_ARG); } - newdssLength += continueHeaderLength; + newdssLength += (continueHeaderLength-2); // calculate the number of bytes to shift - if (i == (continueDssHeaderCount - 1)) + if (i != (continueDssHeaderCount - 1)) bytesToShift = DssConstants.MAX_DSS_LENGTH; else bytesToShift = dssLength; - tempPos -= (shiftSize - 1); - System.arraycopy(buffer, tempPos, buffer, tempPos - bytesToShift + - shiftSize , bytesToShift); - tempPos -= bytesToShift; - tempPos += (shiftSize + 1); + tempPos -= (bytesToShift - 2); + System.arraycopy(buffer, tempPos - shiftSize, buffer, tempPos, + bytesToShift); } // reposition the start of the data after the final DSS shift. pos = tempPos; + dssLength += newdssLength; } /** 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?view=diff&rev=534969&r1=534968&r2=534969 ============================================================================== --- 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 Thu May 3 12:29:25 2007 @@ -85,4 +85,6 @@ Fetched a row, c2.length=12750 JIRA-1454 repro with c2 len=12749 Fetched a row, c2.length=12749 +JIRA Test 1533(a) successful (no exception) +JIRA Test 1533(b) successful (no exception) 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?view=diff&rev=534969&r1=534968&r2=534969 ============================================================================== --- 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 Thu May 3 12:29:25 2007 @@ -85,4 +85,6 @@ Fetched a row, c2.length=12750 JIRA-1454 repro with c2 len=12749 Fetched a row, c2.length=12749 +JIRA Test 1533(a) successful (no exception) +JIRA Test 1533(b) successful (no exception) 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?view=diff&rev=534969&r1=534968&r2=534969 ============================================================================== --- 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 Thu May 3 12:29:25 2007 @@ -85,4 +85,6 @@ Fetched a row, c2.length=12750 JIRA-1454 repro with c2 len=12749 Fetched a row, c2.length=12749 +JIRA Test 1533(a) successful (no exception) +JIRA Test 1533(b) successful (no exception) 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?view=diff&rev=534969&r1=534968&r2=534969 ============================================================================== --- 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 Thu May 3 12:29:25 2007 @@ -45,6 +45,15 @@ { private static Connection conn = null; + + private static String[] testObjects = // string array for cleaning up + {"table t1", "table tab1", "table t2", "table bigtab", "table tstab", + "table doubletab", "table numtab", "table Numeric_Tab", "table jira614", + "table jira614_a", "table jira428", "table jira125", + "table jira125125125125125125125125125125125125125125125125125125125125125125125125125125125125125125125", + "table jira1533_a", "table jira1533_b"}; + + public static void main (String args[]) { try @@ -307,6 +316,8 @@ jira125Test(conn); jira1454Test(conn); jira428Test(conn); + jira1533Test_a(conn); + jira1533Test_b(conn); conn.close(); System.out.println("prepStmt Test Ends"); } @@ -990,6 +1001,107 @@ while (rs.next()); System.out.println("Iteration 1 successful: " + (nCols + 1) + " parameter markers successfully prepared and executed."); + } + // Jira 1533 involves two different bugs regarding the handling of large + // amounts of parameter data: first, the Network Server was incorrectly + // handling the desegmentation of continued DSS segements, and second, + // the Network Server was using the wrong heuristic to determine whether + // long string data was being flowed in-line or externalized. + // + // Tests "a" and "b" provoke two different forms of this problem, one + // with just a single continued segement, and one with several continuations + private static void jira1533Test_a(Connection conn) + throws Exception + { + Statement stmt = conn.createStatement(); + PreparedStatement ps ; + try { stmt.execute("drop table jira1533_a"); } catch (Throwable t) { } + stmt.execute("create table jira1533_a (aa BIGINT NOT NULL, "+ + "bbbbbb BIGINT DEFAULT 0 NOT NULL,"+ + " cccc VARCHAR(40), ddddddddddd BIGINT, eeeeee VARCHAR(128),"+ + " ffffffffffffffffff VARCHAR(128),"+ + "ggggggggg BLOB(2G), hhhhhhhhh VARCHAR(128), "+ + "iiiiiiii VARCHAR(128), jjjjjjjjjjjjjj BIGINT,"+ + "kkkkkkkk CHAR(1) DEFAULT 'f', "+ + "llllllll CHAR(1) DEFAULT 'f', "+ + "mmmmmmmmmmmmm CHAR(1) DEFAULT 'f')"); + stmt.close(); + ps = conn.prepareStatement( + "INSERT INTO jira1533_a (aa,bbbbbb,cccc,ddddddddddd,eeeeee,"+ + " ffffffffffffffffff,"+ + "ggggggggg,hhhhhhhhh,iiiiiiii,jjjjjjjjjjjjjj,kkkkkkkk,"+ + "llllllll,mmmmmmmmmmmmm)"+ + " VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"); + String blobStr = makeString(32584); + ps.setLong(1,5); + ps.setLong(2,1); + ps.setString(3,"AAAAAAAAAAA"); + ps.setLong(4,30000); + ps.setString(5,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + ps.setString(6,"AAAAAAAAAAA"); + ps.setBytes(7,blobStr.getBytes()); + ps.setString(8,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + ps.setString(9,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + ps.setLong(10,1); + ps.setString(11,"1"); + ps.setString(12,"1"); + ps.setString(13,"1"); + ps.execute(); + ps.close(); + System.out.println("JIRA Test 1533(a) successful (no exception)"); + } + private static void jira1533Test_b(Connection conn) + throws Exception + { + Statement stmt = conn.createStatement(); + PreparedStatement ps ; + try { stmt.execute("drop table jira1533_b"); } catch (Throwable t) { } + stmt.execute("create table jira1533_b (aa BIGINT NOT NULL, "+ + "bbbbbb BIGINT DEFAULT 0 NOT NULL,"+ + " cccc VARCHAR(40), ddddddddddd BIGINT, eeeeee VARCHAR(128),"+ + " ffffffffffffffffff VARCHAR(128),"+ + "g1 BLOB(2G),g2 BLOB(2G),g3 BLOB(2G),g4 BLOB(2G),"+ + "ggggggggg BLOB(2G), hhhhhhhhh VARCHAR(128), "+ + "iiiiiiii VARCHAR(128), jjjjjjjjjjjjjj BIGINT,"+ + "kkkkkkkk CHAR(1) DEFAULT 'f', "+ + "llllllll CHAR(1) DEFAULT 'f', "+ + "mmmmmmmmmmmmm CHAR(1) DEFAULT 'f')"); + stmt.close(); + ps = conn.prepareStatement( + "INSERT INTO jira1533_b (aa,bbbbbb,cccc,ddddddddddd,eeeeee,"+ + " ffffffffffffffffff,"+ + "g1,g2,g3,g4,"+ + "ggggggggg,hhhhhhhhh,iiiiiiii,jjjjjjjjjjjjjj,kkkkkkkk,"+ + "llllllll,mmmmmmmmmmmmm)"+ + " VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); + String blobStr = makeString(32584); + ps.setLong(1,5); + ps.setLong(2,1); + ps.setString(3,"AAAAAAAAAAA"); + ps.setLong(4,30000); + ps.setString(5,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + ps.setString(6,"AAAAAAAAAAA"); + ps.setBytes(7,blobStr.getBytes()); + ps.setBytes(8,blobStr.getBytes()); + ps.setBytes(9,blobStr.getBytes()); + ps.setBytes(10,blobStr.getBytes()); + ps.setBytes(11,blobStr.getBytes()); + ps.setString(12,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + ps.setString(13,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + ps.setLong(14,1); + ps.setString(15,"1"); + ps.setString(16,"1"); + ps.setString(17,"1"); + ps.execute(); + ps.close(); + System.out.println("JIRA Test 1533(b) successful (no exception)"); + } + private static String makeString(int length) + { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < length; i++) + buf.append("X"); + return buf.toString(); } // Jira 428 involves large batch sizes for Statement.addBatch and // Statement.executeBatch. Currently, there is a hard DRDA limit of