From derby-commits-return-7329-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Wed May 16 02:59:55 2007 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 10173 invoked from network); 16 May 2007 02:59:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 May 2007 02:59:54 -0000 Received: (qmail 26016 invoked by uid 500); 16 May 2007 03:00:01 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 25988 invoked by uid 500); 16 May 2007 03:00:00 -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 25977 invoked by uid 99); 16 May 2007 03:00:00 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 May 2007 20:00:00 -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; Tue, 15 May 2007 19:59:53 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 7AE651A9838; Tue, 15 May 2007 19:59:33 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r538413 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/derbynet/ testing/org/apache/derbyTesting/functionTests/tes... Date: Wed, 16 May 2007 02:59:33 -0000 To: derby-commits@db.apache.org From: bpendleton@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070516025933.7AE651A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bpendleton Date: Tue May 15 19:59:32 2007 New Revision: 538413 URL: http://svn.apache.org/viewvc?view=rev&rev=538413 Log: DERBY-2558: Client throws JDK exception rather than parameter out of range The client implementation throws an ArrayIndexOutOfBoundsException rather than the expected: ERROR XCL13: The parameter position '2' is out of range. The number of parameters for this prepared statement is '1'. The issue is that the 4-argument overload of setObject was missing the code to validate the parameterIndex; this code is present in the other overloads of setObject. This change adds the parameterIndex validation call, and also adds tests. Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij2.out db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij2.sql Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java?view=diff&rev=538413&r1=538412&r2=538413 ============================================================================== --- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java (original) +++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java Tue May 15 19:59:32 2007 @@ -1488,6 +1488,7 @@ Object x, int targetJdbcType, int scale) throws SqlException { + checkForValidParameterIndex(parameterIndex); checkForValidScale(scale); // JDBC 4.0 requires us to throw SQLFeatureNotSupportedException for Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij2.out URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij2.out?view=diff&rev=538413&r1=538412&r2=538413 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij2.out (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij2.out Tue May 15 19:59:32 2007 @@ -91,6 +91,25 @@ ij> -- note that the using part was, however, executed... drop table s; 0 rows inserted/updated/deleted +ij> -- DERBY-2558: Verify that we get a reasonable message when the 'dimension' +-- of the 'using-set' does not match the 'dimension' of the prepared statement: +create table t2558 (i int); +0 rows inserted/updated/deleted +ij> insert into t2558 values (3), (4); +2 rows inserted/updated/deleted +ij> -- First two statements below should fail. Third one should work. +execute 'select * from t2558 where i = ?' using 'values (3,4)'; +IJ WARNING: Autocommit may close using result set +ERROR XCL13: The parameter position '2' is out of range. The number of parameters for this prepared statement is '1'. +ij> execute 'select * from t2558 where i in (?,?,?)' using 'values (3,4)'; +IJ WARNING: Autocommit may close using result set +ERROR 07000: At least one parameter to the current statement is uninitialized. +ij> execute 'select * from t2558 where i = ? or i = ?' using 'values (3,4)'; +IJ WARNING: Autocommit may close using result set +I +----------- +3 +4 ij> -- bug 5926 - make sure the using clause result set got closed drop table t; 0 rows inserted/updated/deleted Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java?view=diff&rev=538413&r1=538412&r2=538413 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/PrepareStatementTest.java Tue May 15 19:59:32 2007 @@ -288,6 +288,29 @@ assertSQLState("07000", e); } pSt.close(); + + // Some test cases for DERBY-2558, involving validation of the + // parameterIndex argument to the 4-argument overload of setObject + // + pSt = prepareStatement("create table d2558 (i int)"); + assertUpdateCount(pSt, 0); + pSt.close(); + pSt = prepareStatement("insert into d2558 values (3), (4)"); + assertUpdateCount(pSt, 2); + pSt.close(); + pSt = prepareStatement("select * from d2558 where i = ?"); + pSt.setObject(1,new Integer(3),java.sql.Types.INTEGER,0); + try { + // There's only 1 parameter marker, so this should fail: + pSt.setObject(2,new Integer(4), java.sql.Types.INTEGER,0); + rs = pSt.executeQuery(); + rs.close(); + fail("Exception expected above!"); + } catch (SQLException e) { + assertSQLState("XCL13", e); + } + pSt.close(); + } Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij2.sql URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij2.sql?view=diff&rev=538413&r1=538412&r2=538413 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij2.sql (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij2.sql Tue May 15 19:59:32 2007 @@ -67,6 +67,15 @@ -- note that the using part was, however, executed... drop table s; +-- DERBY-2558: Verify that we get a reasonable message when the 'dimension' +-- of the 'using-set' does not match the 'dimension' of the prepared statement: +create table t2558 (i int); +insert into t2558 values (3), (4); +-- First two statements below should fail. Third one should work. +execute 'select * from t2558 where i = ?' using 'values (3,4)'; +execute 'select * from t2558 where i in (?,?,?)' using 'values (3,4)'; +execute 'select * from t2558 where i = ? or i = ?' using 'values (3,4)'; + -- bug 5926 - make sure the using clause result set got closed drop table t; create table t(c1 int);