Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 68434 invoked from network); 21 Feb 2008 18:24:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Feb 2008 18:24:56 -0000 Received: (qmail 18831 invoked by uid 500); 21 Feb 2008 18:24:51 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 18756 invoked by uid 500); 21 Feb 2008 18:24:50 -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 18739 invoked by uid 99); 21 Feb 2008 18:24:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Feb 2008 10:24:50 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED 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, 21 Feb 2008 18:24:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0E65F1A9832; Thu, 21 Feb 2008 10:24:26 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r629903 - in /db/derby/code/branches/10.3/java: client/org/apache/derby/client/am/ client/org/apache/derby/client/net/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ Date: Thu, 21 Feb 2008 18:24:18 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080221182428.0E65F1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kmarsden Date: Thu Feb 21 10:24:16 2008 New Revision: 629903 URL: http://svn.apache.org/viewvc?rev=629903&view=rev Log: DERBY-2653 Expose existing auto-generated key functionality through more JDBC APIs in Derby Client. dd client support for columnIndex API's: Connection.prepareStatement(String sql, int[] columnIndexes); Statement.execute(String sql, int[] columIndexes); Statement.executeUpdate(String sql, int[] columnIndexes); port from trunk revision 629566 Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/CallableStatement.java db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Connection.java db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/DatabaseMetaData.java db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement.java db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement40.java db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Statement.java db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Statement40.java db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetConnection.java db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetPreparedStatement.java db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetStatement.java db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoGenJDBC30Test.java Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/CallableStatement.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/CallableStatement.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/CallableStatement.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/CallableStatement.java Thu Feb 21 10:24:16 2008 @@ -88,7 +88,8 @@ String sql, int type, int concurrency, int holdability, ClientPooledConnection cpc) throws SqlException { - super(agent, connection, sql, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null,cpc); + super(agent, connection, sql, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, + null, null,cpc); initCallableStatement(); } @@ -96,7 +97,8 @@ Connection connection, String sql, int type, int concurrency, int holdability) throws SqlException { - super.resetPreparedStatement(agent, connection, sql, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null); + super.resetPreparedStatement(agent, connection, sql, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, + null,null); initCallableStatement(); } Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/ClientJDBCObjectFactory.java Thu Feb 21 10:24:16 2008 @@ -145,6 +145,8 @@ * keys should be returned. * @param columnNames an array of column names indicating the columns that * should be returned from the inserted row or rows. + * @param columnIndexes an array of column indexes indicating the columns + * that should be returned form the inserted row. * @param cpc The ClientPooledConnection wraps the underlying physical * connection associated with this prepared statement * it is used to pass the Statement closed and the Statement @@ -156,7 +158,7 @@ PreparedStatement newPreparedStatement(Agent agent, org.apache.derby.client.am.Connection connection,String sql, int type,int concurrency,int holdability,int autoGeneratedKeys, - String [] columnNames,ClientPooledConnection cpc) + String [] columnNames, int[] columnIndexes, ClientPooledConnection cpc) throws SqlException; @@ -284,6 +286,7 @@ * @param holdability int * @param autoGeneratedKeys int * @param columnNames String[] + * @param columnIndexes int[] * @return a java.sql.Statement implementation * @throws SqlException * @@ -291,7 +294,8 @@ Statement newStatement(Agent agent, org.apache.derby.client.am.Connection connection, int type, int concurrency, int holdability, - int autoGeneratedKeys, String[] columnNames) + int autoGeneratedKeys, String[] columnNames, + int[] columnIndexes) throws SqlException; /** Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Connection.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Connection.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Connection.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Connection.java Thu Feb 21 10:24:16 2008 @@ -415,7 +415,7 @@ java.sql.ResultSet.CONCUR_READ_ONLY, holdability(), java.sql.Statement.NO_GENERATED_KEYS, - null); + null, null); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "prepareStatement", ps); } @@ -464,7 +464,8 @@ } synchronized PreparedStatement prepareDynamicCatalogQuery(String sql) throws SqlException { - PreparedStatement ps = newPreparedStatement_(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY, holdability(), java.sql.Statement.NO_GENERATED_KEYS, null); + PreparedStatement ps = newPreparedStatement_(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY, holdability(), java.sql.Statement.NO_GENERATED_KEYS, null, + null); ps.isCatalogQuery_ = true; ps.prepare(); openStatements_.put(ps, null); @@ -1212,7 +1213,7 @@ resultSetConcurrency, holdability(), java.sql.Statement.NO_GENERATED_KEYS, - null); + null, null); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "prepareStatement", ps); } @@ -1619,7 +1620,7 @@ resultSetConcurrency, resultSetHoldability, java.sql.Statement.NO_GENERATED_KEYS, - null); + null, null); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "prepareStatement", ps); } @@ -1637,10 +1638,12 @@ int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys, - String[] columnNames) throws SqlException { + String[] columnNames, + int[] columnIndexes) throws SqlException { checkForClosedConnection(); resultSetType = downgradeResultSetType(resultSetType); - PreparedStatement ps = newPreparedStatement_(sql, resultSetType, resultSetConcurrency, resultSetHoldability, autoGeneratedKeys, columnNames); + PreparedStatement ps = newPreparedStatement_(sql, resultSetType, resultSetConcurrency, resultSetHoldability, autoGeneratedKeys, columnNames, + columnIndexes); ps.cursorAttributesToSendOnPrepare_ = ps.cacheCursorAttributesToSendOnPrepare(); ps.prepare(); openStatements_.put(ps,null); @@ -1652,7 +1655,8 @@ // to send different attributes, i.e. SENSITIVE DYNAMIC, instead of SENSITIVE STATIC. protected void resetPrepareStatement(PreparedStatement ps) throws SqlException { String cursorAttributesToSendOnPrepare = ps.cursorAttributesToSendOnPrepare_; - resetPreparedStatement_(ps, ps.sql_, ps.resultSetType_, ps.resultSetConcurrency_, ps.resultSetHoldability_, ps.autoGeneratedKeys_, ps.generatedKeysColumnNames_); + resetPreparedStatement_(ps, ps.sql_, ps.resultSetType_, ps.resultSetConcurrency_, ps.resultSetHoldability_, ps.autoGeneratedKeys_, ps.generatedKeysColumnNames_, + ps.generatedKeysColumnIndexes_); ps.cursorAttributesToSendOnPrepare_ = cursorAttributesToSendOnPrepare; ps.prepare(); } @@ -1709,7 +1713,7 @@ java.sql.ResultSet.CONCUR_READ_ONLY, holdability(), autoGeneratedKeys, - null); + null, null); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "prepareStatement", ps); } @@ -1727,10 +1731,20 @@ if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "prepareStatement", sql, columnIndexes); } - checkForClosedConnection(); - throw new SqlException(agent_.logWriter_, - new ClientMessageId (SQLState.NOT_IMPLEMENTED), - "prepareStatement(String, int[])"); + int genKeys = (columnIndexes == null || + columnIndexes.length == 0 + ? Statement.NO_GENERATED_KEYS: + Statement.RETURN_GENERATED_KEYS); + PreparedStatement ps = prepareStatementX(sql, + java.sql.ResultSet.TYPE_FORWARD_ONLY, + java.sql.ResultSet.CONCUR_READ_ONLY, + holdability(), + genKeys, + null, columnIndexes); + if (agent_.loggingEnabled()) { + agent_.logWriter_.traceExit(this, "prepareStatement", ps); + } + return ps; } catch ( SqlException se ) { @@ -1753,7 +1767,7 @@ java.sql.ResultSet.CONCUR_READ_ONLY, holdability(), genKeys, - columnNames); + columnNames, null); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "prepareStatement", ps); } @@ -1799,7 +1813,7 @@ int concurrency, int holdability, int autoGeneratedKeys, - String[] columnNames) throws SqlException; + String[] columnNames, int[] columnIndexes) throws SqlException; protected abstract void resetPreparedStatement_(PreparedStatement ps, String sql, @@ -1807,7 +1821,8 @@ int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys, - String[] columnNames) throws SqlException; + String[] columnNames, + int[] columnIndexes) throws SqlException; protected abstract CallableStatement newCallableStatement_(String sql, int type, Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/DatabaseMetaData.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/DatabaseMetaData.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/DatabaseMetaData.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/DatabaseMetaData.java Thu Feb 21 10:24:16 2008 @@ -2727,7 +2727,7 @@ java.sql.ResultSet.CONCUR_READ_ONLY, connection_.holdability(), java.sql.Statement.NO_GENERATED_KEYS, - null); + null, null); return ps; } Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement.java Thu Feb 21 10:24:16 2008 @@ -195,6 +195,8 @@ * keys should be returned. * @param columnNames an array of column names indicating the columns that * should be returned from the inserted row or rows. + * @param columnIndexes an array of column names indicating the columns that + * should be returned from the inserted row. * @param cpc The ClientPooledConnection wraps the underlying physical * connection associated with this prepared statement * it is used to pass the Statement closed and the Statement @@ -207,10 +209,11 @@ String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, + int[] columnIndexes, ClientPooledConnection cpc) throws SqlException { super(agent, connection, type, concurrency, holdability, - autoGeneratedKeys, columnNames); + autoGeneratedKeys, columnNames, columnIndexes); // PreparedStatement is poolable by default isPoolable = true; initPreparedStatement(sql); @@ -221,8 +224,10 @@ public void resetPreparedStatement(Agent agent, Connection connection, String sql, - int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames) throws SqlException { - super.resetStatement(agent, connection, type, concurrency, holdability, autoGeneratedKeys, columnNames); + int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, + int[] columnIndexes) throws SqlException { + super.resetStatement(agent, connection, type, concurrency, holdability, autoGeneratedKeys, + columnNames, columnIndexes); initPreparedStatement(); initPreparedStatement(sql); } Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement40.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement40.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement40.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/PreparedStatement40.java Thu Feb 21 10:24:16 2008 @@ -82,6 +82,8 @@ * keys should be returned. * @param columnNames an array of column names indicating the columns that * should be returned from the inserted row or rows. + * @param columnIndexes an array of column indexes indicating the columns + * that should be returned from the inserted row. * @param cpc The ClientPooledConnection wraps the underlying physical * connection associated with this prepared statement * it is used to pass the Statement closed and the Statement @@ -92,8 +94,10 @@ public PreparedStatement40(Agent agent, Connection connection, String sql, - int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames,ClientPooledConnection cpc) throws SqlException { - super(agent, connection, sql, type, concurrency, holdability, autoGeneratedKeys, columnNames, cpc); + int type, int concurrency, int holdability, int autoGeneratedKeys, + String[] columnNames, int[] columnIndexes, ClientPooledConnection cpc) throws SqlException { + super(agent, connection, sql, type, concurrency, holdability, autoGeneratedKeys, + columnNames, columnIndexes, cpc); } Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Statement.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Statement.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Statement.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Statement.java Thu Feb 21 10:24:16 2008 @@ -185,6 +185,8 @@ public PreparedStatement preparedStatementForAutoGeneratedKeys_; public ResultSet generatedKeysResultSet_; public String[] generatedKeysColumnNames_; + public int[] generatedKeysColumnIndexes_; + public int autoGeneratedKeys_ = java.sql.Statement.NO_GENERATED_KEYS; // This flag makes sure that only one copy of this statement @@ -264,6 +266,7 @@ preparedStatementForAutoGeneratedKeys_ = null; generatedKeysResultSet_ = null; generatedKeysColumnNames_ = null; + generatedKeysColumnIndexes_ = null; autoGeneratedKeys_ = java.sql.Statement.NO_GENERATED_KEYS; // these members were not initialized @@ -305,19 +308,21 @@ // For jdbc 2 statements with scroll attributes public Statement(Agent agent, Connection connection, int type, int concurrency, int holdability, - int autoGeneratedKeys, String[] columnNames) throws SqlException { + int autoGeneratedKeys, String[] columnNames, int[] columnIndexes) throws SqlException { this(agent, connection); - initStatement(type, concurrency, holdability, autoGeneratedKeys, columnNames); + initStatement(type, concurrency, holdability, autoGeneratedKeys, columnNames, + columnIndexes); } public void resetStatement(Agent agent, Connection connection, int type, int concurrency, int holdability, - int autoGeneratedKeys, String[] columnNames) throws SqlException { + int autoGeneratedKeys, String[] columnNames, int[] columnIndexes) throws SqlException { resetStatement(agent, connection); - initStatement(type, concurrency, holdability, autoGeneratedKeys, columnNames); + initStatement(type, concurrency, holdability, autoGeneratedKeys, columnNames, columnIndexes); } private void initStatement(int type, int concurrency, int holdability, - int autoGeneratedKeys, String[] columnNames) throws SqlException { + int autoGeneratedKeys, String[] columnNames, + int[] columnIndexes) throws SqlException { switch (type) { case java.sql.ResultSet.TYPE_FORWARD_ONLY: case java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE: @@ -367,6 +372,7 @@ } generatedKeysColumnNames_ = columnNames; + generatedKeysColumnIndexes_ = columnIndexes; } /* (non-Javadoc) @@ -1189,13 +1195,19 @@ public int executeUpdate(String sql, int columnIndexes[]) throws SQLException { try { - if (agent_.loggingEnabled()) { - agent_.logWriter_.traceEntry(this, "executeUpdate", sql, columnIndexes); + synchronized (connection_) { + if (agent_.loggingEnabled()) { + agent_.logWriter_.traceEntry(this, "executeUpdate", sql, columnIndexes); + } + if (columnIndexes != null && columnIndexes.length > 0) + autoGeneratedKeys_ = Statement.RETURN_GENERATED_KEYS; + generatedKeysColumnIndexes_ = columnIndexes; + int updateValue = executeUpdateX(sql); + if (agent_.loggingEnabled()) { + agent_.logWriter_.traceExit(this, "executeUpdate", updateValue); + } + return updateValue; } - checkForClosedStatement(); - throw new SqlException(agent_.logWriter_, - new ClientMessageId(SQLState.NOT_IMPLEMENTED), - "executeUpdate(String, int[])"); } catch ( SqlException se ) { @@ -1250,13 +1262,19 @@ public boolean execute(String sql, int columnIndexes[]) throws SQLException { try { - if (agent_.loggingEnabled()) { - agent_.logWriter_.traceEntry(this, "execute", sql, columnIndexes); + synchronized(connection_) { + if (agent_.loggingEnabled()) { + agent_.logWriter_.traceEntry(this, "execute", sql, columnIndexes); + } + if (columnIndexes != null && columnIndexes.length > 0) + autoGeneratedKeys_ = Statement.RETURN_GENERATED_KEYS; + generatedKeysColumnIndexes_ = columnIndexes; + boolean b = executeX(sql); + if (agent_.loggingEnabled()) { + agent_.logWriter_.traceExit(this, "execute", b); + } + return b; } - checkForClosedStatement(); - throw new SqlException(agent_.logWriter_, - new ClientMessageId(SQLState.NOT_IMPLEMENTED), - "execute(String, int[])"); } catch ( SqlException se ) { @@ -2634,7 +2652,7 @@ java.sql.ResultSet.CONCUR_READ_ONLY, java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT, java.sql.Statement.NO_GENERATED_KEYS, - null); + null, null); // need a special case for Derby, since the attribute has to go through the wire. // This same special casing for Derby is already in place in method PS.cacheCursorAttributesToSendOnPrepare() as called by prepareStatementX(). // We need to figure how some way to get code reuse here, ie. to consolidate to just one special casing rather than two? @@ -2669,14 +2687,22 @@ "Statement.execute()/executeQuery()"); } - - if (sqlUpdateMode_ == isInsertSql__ && - generatedKeysColumnNames_ != null && + if (sqlUpdateMode_ == isInsertSql__) + { + if (generatedKeysColumnNames_ != null && generatedKeysColumnNames_.length > 1) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.INVALID_COLUMN_ARRAY_LENGTH), new Integer(generatedKeysColumnNames_.length)); - } + } + + if (generatedKeysColumnIndexes_ != null && + generatedKeysColumnIndexes_.length > 1) { + throw new SqlException(agent_.logWriter_, + new ClientMessageId(SQLState.INVALID_COLUMN_ARRAY_LENGTH), + new Integer(generatedKeysColumnIndexes_.length)); + } + } } Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Statement40.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Statement40.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Statement40.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/am/Statement40.java Thu Feb 21 10:24:16 2008 @@ -49,15 +49,17 @@ * @param holdability int * @param autoGeneratedKeys int * @param columnNames String[] + * @param columnIndexes int[] * @throws SqlException * */ public Statement40(Agent agent, Connection connection, int type, int concurrency, int holdability, - int autoGeneratedKeys, String[] columnNames) + int autoGeneratedKeys, String[] columnNames, + int[] columnIndexes) throws SqlException { super(agent,connection,type,concurrency,holdability,autoGeneratedKeys, - columnNames); + columnNames, columnIndexes); } /** Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl.java Thu Feb 21 10:24:16 2008 @@ -175,10 +175,11 @@ org.apache.derby.client.am.Connection connection, String sql,int type,int concurrency,int holdability, int autoGeneratedKeys,String [] columnNames, + int[] columnIndexes, ClientPooledConnection cpc) throws SqlException { return new PreparedStatement(agent,connection,sql,type,concurrency, - holdability,autoGeneratedKeys,columnNames,cpc); + holdability,autoGeneratedKeys,columnNames, columnIndexes, cpc); } /** @@ -311,6 +312,7 @@ * @param holdability int * @param autoGeneratedKeys int * @param columnNames String[] + * @param columnIndexes int[] * @return a java.sql.Statement implementation * @throws SqlException * @@ -318,10 +320,11 @@ public Statement newStatement(Agent agent, org.apache.derby.client.am.Connection connection, int type, int concurrency, int holdability, - int autoGeneratedKeys, String[] columnNames) + int autoGeneratedKeys, String[] columnNames, + int[] columnIndexes) throws SqlException { return new Statement(agent,connection,type,concurrency,holdability, - autoGeneratedKeys,columnNames); + autoGeneratedKeys,columnNames, columnIndexes); } /** Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/ClientJDBCObjectFactoryImpl40.java Thu Feb 21 10:24:16 2008 @@ -158,6 +158,8 @@ * keys should be returned. * @param columnNames an array of column names indicating the columns that * should be returned from the inserted row or rows. + * @param columnIndexes an array of column indexes indicating the columns + * that should be returned from the inserted row. * @param cpc The ClientPooledConnection wraps the underlying physical * connection associated with this prepared statement * it is used to pass the Statement closed and the Statement @@ -171,10 +173,11 @@ org.apache.derby.client.am.Connection connection, String sql,int type,int concurrency, int holdability,int autoGeneratedKeys, - String [] columnNames,ClientPooledConnection cpc) + String [] columnNames, + int[] columnIndexes, ClientPooledConnection cpc) throws SqlException { return new PreparedStatement40(agent,connection,sql,type,concurrency, - holdability,autoGeneratedKeys,columnNames,cpc); + holdability,autoGeneratedKeys,columnNames,columnIndexes, cpc); } @@ -308,6 +311,7 @@ * @param holdability int * @param autoGeneratedKeys int * @param columnNames String[] + * @param columnIndexes int[] * @return a java.sql.Statement implementation * @throws SqlException * @@ -315,10 +319,11 @@ public Statement newStatement(Agent agent, org.apache.derby.client.am.Connection connection, int type, int concurrency, int holdability, - int autoGeneratedKeys, String[] columnNames) + int autoGeneratedKeys, String[] columnNames, + int[] columnIndexes) throws SqlException { return new Statement40(agent,connection,type,concurrency,holdability, - autoGeneratedKeys,columnNames); + autoGeneratedKeys,columnNames, columnIndexes); } /** Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetConnection.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetConnection.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetConnection.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetConnection.java Thu Feb 21 10:24:16 2008 @@ -1107,11 +1107,13 @@ return new NetPreparedStatement(netAgent_, this, sql, section,pooledConnection_).preparedStatement_; } - protected PreparedStatement newPreparedStatement_(String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames) throws SqlException { + protected PreparedStatement newPreparedStatement_(String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, + int[] columnIndexes) throws SqlException { //passing the pooledConnection_ object which will be used to raise //StatementEvents to the PooledConnection - return new NetPreparedStatement(netAgent_, this, sql, type, concurrency, holdability, autoGeneratedKeys, columnNames,pooledConnection_).preparedStatement_; + return new NetPreparedStatement(netAgent_, this, sql, type, concurrency, holdability, autoGeneratedKeys, columnNames, + columnIndexes, pooledConnection_).preparedStatement_; } protected void resetPreparedStatement_(PreparedStatement ps, @@ -1120,8 +1122,10 @@ int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys, - String[] columnNames) throws SqlException { - ((NetPreparedStatement) ps.materialPreparedStatement_).resetNetPreparedStatement(netAgent_, this, sql, resultSetType, resultSetConcurrency, resultSetHoldability, autoGeneratedKeys, columnNames); + String[] columnNames, + int[] columnIndexes) throws SqlException { + ((NetPreparedStatement) ps.materialPreparedStatement_).resetNetPreparedStatement(netAgent_, this, sql, resultSetType, resultSetConcurrency, + resultSetHoldability, autoGeneratedKeys, columnNames, columnIndexes); } Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetPreparedStatement.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetPreparedStatement.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetPreparedStatement.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetPreparedStatement.java Thu Feb 21 10:24:16 2008 @@ -80,6 +80,9 @@ * @param columnNames A String array of column names indicating * the columns that should be returned * from the inserted row or rows. + * @param columnIndexes An int array of column indexes indicating + * the column that should be returned from + * the inserted row. * @param cpc The ClientPooledConnection wraps the underlying physical * connection associated with this prepared statement * it is used to pass the Statement closed and the Statement @@ -88,17 +91,20 @@ * @throws SqlException * */ - NetPreparedStatement(NetAgent netAgent, NetConnection netConnection, String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, ClientPooledConnection cpc) throws SqlException { + NetPreparedStatement(NetAgent netAgent, NetConnection netConnection, String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, + int[] columnIndexes, ClientPooledConnection cpc) throws SqlException { this(ClientDriver.getFactory().newPreparedStatement(netAgent, netConnection, sql, type, concurrency, holdability, - autoGeneratedKeys, columnNames, cpc), + autoGeneratedKeys, columnNames, columnIndexes, cpc), netAgent, netConnection ); } - void resetNetPreparedStatement(NetAgent netAgent, NetConnection netConnection, String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames) throws SqlException { - preparedStatement_.resetPreparedStatement(netAgent, netConnection, sql, type, concurrency, holdability, autoGeneratedKeys, columnNames); + void resetNetPreparedStatement(NetAgent netAgent, NetConnection netConnection, String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, + int[] columnIndexes) throws SqlException { + preparedStatement_.resetPreparedStatement(netAgent, netConnection, sql, type, concurrency, holdability, autoGeneratedKeys, + columnNames, columnIndexes); resetNetPreparedStatement(preparedStatement_, netAgent, netConnection); } Modified: db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetStatement.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetStatement.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetStatement.java (original) +++ db/derby/code/branches/10.3/java/client/org/apache/derby/client/net/NetStatement.java Thu Feb 21 10:24:16 2008 @@ -92,13 +92,16 @@ // Called by abstract Connection.createStatement().newStatement() for jdbc 2 statements with scroll attributes NetStatement(NetAgent netAgent, NetConnection netConnection, int type, int concurrency, int holdability) throws SqlException { - this(ClientDriver.getFactory().newStatement(netAgent, netConnection, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null), + this(ClientDriver.getFactory().newStatement(netAgent, netConnection, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, + null,null + ), netAgent, netConnection); } void resetNetStatement(NetAgent netAgent, NetConnection netConnection, int type, int concurrency, int holdability) throws SqlException { - statement_.resetStatement(netAgent, netConnection, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null); + statement_.resetStatement(netAgent, netConnection, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, + null, null); resetNetStatement(statement_, netAgent, netConnection); } Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoGenJDBC30Test.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoGenJDBC30Test.java?rev=629903&r1=629902&r2=629903&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoGenJDBC30Test.java (original) +++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoGenJDBC30Test.java Thu Feb 21 10:24:16 2008 @@ -947,58 +947,6 @@ } /** - * Verifies that an exception is raised if a columnIndexes array is passed, - * which signals the driver that the auto-generated keys indicated in the - * given array should be made available for retrieval (feature not - * supported). - * Old master Test21, Test21ps - * Expected result: Exception 0A000 should occur. - * @throws SQLException - */ - public void testColumnIndexesNotImpl() throws SQLException - { - /* As of DERBY-2631 we support this with embedded. So do nothing - * for this test fixture; we'll test the functionality as part - * of a separate fixture. - */ - if (usingEmbedded()) - return; - - Statement s = createStatement(); - int colPositions[] = new int[1]; - colPositions[0] = 1; - - String sql="insert into t11_AutoGen(c11) " + - "select c21 from t21_noAutoGen"; - - try { - s.execute(sql, colPositions); - fail("Expected s.execute to fail"); - } catch (SQLException se) { - assertSQLState("0A000", se.getSQLState(), se); - } - - try { - s.executeUpdate(sql, colPositions); - fail("Expected s.executeUpdate to fail"); - } catch (SQLException se) { - assertSQLState("0A000", se.getSQLState(), se); - } - - try { - /* Deliberately not adding this prepareStatement wrapper to - * BaseJDBCTestCase.java because Derby doesn't support passing - * the array. - */ - Connection conn = getConnection(); - PreparedStatement ps=conn.prepareStatement(sql, colPositions); - fail("Expected prepareStatement to fail"); - } catch (SQLException se) { - assertSQLState("0A000", se.getSQLState(), se); - } - } - - /** * Test that use of columnIndexes to indicate which keys should be * made available works as expected. * @@ -1006,20 +954,26 @@ */ public void testColumnIndexes() throws SQLException { - /* Not supported for Derby client. We check the "not supported" - * error message as part of a different fixture. - */ - if (usingDerbyNetClient()) - return; // Valid (typical) usage. int [] colIndexes = new int [] { 2 }; testUserGivenColumns(colIndexes, null, 1); + - // Non-existent column index. + // Mulitple columns. one not an identity column. + colIndexes = new int[] {1,2}; + testUserGivenColumnsError(colIndexes, null); + + + // Derby client can't differentiate between + // valid and invalid identity columns. So the + // other tests do not apply. + if (usingDerbyNetClient()) + return; - colIndexes[0] = 100; + // Non-existent column index. + colIndexes = new int[] {100}; testUserGivenColumnsError(colIndexes, null); // Valid column index but not an auto-gen column. @@ -1040,10 +994,6 @@ colIndexes[1] = 100; testUserGivenColumnsError(colIndexes, null); - // Multiple col indexes, one of which is not an auto-gen column. - - colIndexes[1] = 1; - testUserGivenColumnsError(colIndexes, null); /* Multiple col indexes, one of which is invalid and another * of which is not an auto-gen column.