db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r628780 - in /db/derby/code/trunk/java/client/org/apache/derby/client/am: PreparedStatement.java Statement.java
Date Mon, 18 Feb 2008 15:20:29 GMT
Author: kmarsden
Date: Mon Feb 18 07:20:26 2008
New Revision: 628780

URL: http://svn.apache.org/viewvc?rev=628780&view=rev
Log:
DERBY-3426 Remove unused code for autogenerated keys columnNames


Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java

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?rev=628780&r1=628779&r2=628780&view=diff
==============================================================================
--- 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 Mon
Feb 18 07:20:26 2008
@@ -301,13 +301,7 @@
     void prepare() throws SqlException {
         try {
             // flow prepare, no static initialization is needed
-            // already checked if columnNames is not null and server supports select from
insert
-            // in prepareStatementX()
-            if (sqlUpdateMode_ == isInsertSql__ && generatedKeysColumnNames_ != null)
{
-                flowPrepareForSelectFromInsert();
-            } else {
-                flowPrepareDescribeInputOutput();
-            }
+            flowPrepareDescribeInputOutput();
         } catch (SqlException e) {
             this.markClosed();
             throw e;
@@ -1925,14 +1919,6 @@
         return array;
     }
 
-    void flowPrepareForSelectFromInsert() throws SqlException {
-        agent_.beginWriteChain(this);
-        writePrepareDescribeInputOutput(constructSelectFromInsertSQL(sql_), section_);
-        agent_.flow(this);
-        readPrepareDescribeInputOutput();
-        agent_.endReadChain();
-    }
-
     void writePrepareDescribeInputOutput(String sql,
                                          Section section) throws SqlException {
         // Notice that sql_ is passed in since in general ad hoc sql must be passed in for
unprepared statements
@@ -2020,30 +2006,22 @@
 
                 chainAutoCommit = connection_.willAutoCommitGenerateFlow() && isAutoCommittableStatement_;
 
-                if (sqlUpdateMode_ == isInsertSql__ && generatedKeysColumnNames_
!= null) {
-                    writeOpenQuery(section_,
-                            fetchSize_,
-                            resultSetType_,
-                            numInputColumns,
-                            parameterMetaData_,
-                            parameters_);
-                } else {
-                    boolean chainOpenQueryForAutoGeneratedKeys = (sqlUpdateMode_ == isInsertSql__
&& autoGeneratedKeys_ == RETURN_GENERATED_KEYS);
-                    writeExecute(section_,
-                            parameterMetaData_,
-                            parameters_,
-                            numInputColumns,
-                            outputExpected,
-                            (chainAutoCommit || chainOpenQueryForAutoGeneratedKeys)// chain
flag
-                    ); // chain flag
-
-                    if (chainOpenQueryForAutoGeneratedKeys) {
-                        prepareAutoGeneratedKeysStatement();
-                        writeOpenQuery(preparedStatementForAutoGeneratedKeys_.section_,
-                                preparedStatementForAutoGeneratedKeys_.fetchSize_,
-                                preparedStatementForAutoGeneratedKeys_.resultSetType_);
-                    }
+                boolean chainOpenQueryForAutoGeneratedKeys = (sqlUpdateMode_ == isInsertSql__
&& autoGeneratedKeys_ == RETURN_GENERATED_KEYS);
+                writeExecute(section_,
+                        parameterMetaData_,
+                        parameters_,
+                        numInputColumns,
+                        outputExpected,
+                        (chainAutoCommit || chainOpenQueryForAutoGeneratedKeys)// chain flag
+                ); // chain flag
+
+                if (chainOpenQueryForAutoGeneratedKeys) {
+                    prepareAutoGeneratedKeysStatement();
+                    writeOpenQuery(preparedStatementForAutoGeneratedKeys_.section_,
+                            preparedStatementForAutoGeneratedKeys_.fetchSize_,
+                            preparedStatementForAutoGeneratedKeys_.resultSetType_);
                 }
+                
 
                 if (chainAutoCommit) {
                     // we have encountered an error in writing the execute, so do not
@@ -2105,14 +2083,7 @@
                     scrollableRS.readPositioningFetch_();
                 }
 
-                if (sqlUpdateMode_ == isInsertSql__ && generatedKeysColumnNames_
!= null) {
-                    readOpenQuery();
-                    if (resultSet_ != null) {
-                        generatedKeysResultSet_ = resultSet_;
-                        resultSet_ = null;
-                        updateCount_ = 1;
-                    }
-                } else {
+                else {
                     readExecute();
 
                     if (sqlUpdateMode_ == isInsertSql__ && autoGeneratedKeys_ ==
RETURN_GENERATED_KEYS) {

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java?rev=628780&r1=628779&r2=628780&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java Mon Feb 18 07:20:26
2008
@@ -1941,21 +1941,13 @@
                     }
                     writeExecuteImmediate(sql, newSection);
                 }
-                // if sql is an insert and columnNames is not null, and
-                // then transform the insert statement into an
-                // select from insert statement.
-                // else chain an "select from identity_val_local()" to the insert statement
-                else if (sqlUpdateMode_ == isInsertSql__ && generatedKeysColumnNames_
!= null) {
-                    newSection = agent_.sectionManager_.getDynamicSection(resultSetHoldability_);
-                    writePrepareDescribeOutput(constructSelectFromInsertSQL(sql), newSection);
-                    writeOpenQuery(newSection,
-                            fetchSize_,
-                            resultSetType_);
-                } else {
+            
+               else {
                     newSection = agent_.sectionManager_.getDynamicSection(resultSetHoldability_);
 
                     writeExecuteImmediate(sql, newSection);
                     if (sqlUpdateMode_ == isInsertSql__ && autoGeneratedKeys_ ==
RETURN_GENERATED_KEYS) {
+                        // chain a "select from identity_val_local()" to the insert statement
                         prepareAutoGeneratedKeysStatement();
                         writeOpenQuery(preparedStatementForAutoGeneratedKeys_.section_,
                                 preparedStatementForAutoGeneratedKeys_.fetchSize_,
@@ -2023,24 +2015,13 @@
                 if (scrollableRS != null && !scrollableRS.isRowsetCursor_) {
                     scrollableRS.readPositioningFetch_();
                 }
+                readExecuteImmediate();
 
-                if (sqlUpdateMode_ == isInsertSql__ && generatedKeysColumnNames_
!= null) {
-                    readPrepareDescribeOutput();
-                    readOpenQuery();
-                    if (resultSet_ != null) {
-                        generatedKeysResultSet_ = resultSet_;
-                        resultSet_ = null;
-                        updateCount_ = 1;
-                    }
-                } else {
-                    readExecuteImmediate();
-
-                    if (sqlUpdateMode_ == isInsertSql__ && autoGeneratedKeys_ ==
RETURN_GENERATED_KEYS) {
-                        readPrepareAutoGeneratedKeysStatement();
-                        preparedStatementForAutoGeneratedKeys_.readOpenQuery();
-                        generatedKeysResultSet_ = preparedStatementForAutoGeneratedKeys_.resultSet_;
-                        preparedStatementForAutoGeneratedKeys_.resultSet_ = null;
-                    }
+                if (sqlUpdateMode_ == isInsertSql__ && autoGeneratedKeys_ == RETURN_GENERATED_KEYS)
{
+                    readPrepareAutoGeneratedKeysStatement();
+                    preparedStatementForAutoGeneratedKeys_.readOpenQuery();
+                    generatedKeysResultSet_ = preparedStatementForAutoGeneratedKeys_.resultSet_;
+                    preparedStatementForAutoGeneratedKeys_.resultSet_ = null;
                 }
 
                 if (connection_.autoCommit_) {
@@ -2661,19 +2642,7 @@
                 : cursorAttributes.toString();
     }
 
-    protected String constructSelectFromInsertSQL(String sql) {
-        String temp = "select ";
-        int numOfColumns = generatedKeysColumnNames_.length;
-
-        for (int i = 0; i < numOfColumns; i++) {
-            temp += generatedKeysColumnNames_[i];
-            if ((i + 1) < numOfColumns) {
-                temp += ",";
-            }
-        }
-        temp += (" from final table (" + sql + ")");
-        return temp;
-    }
+  
 
     void getPreparedStatementForAutoGeneratedKeys() throws SqlException {
         if (preparedStatementForAutoGeneratedKeys_ == null) {



Mime
View raw message