db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1478641 - in /db/derby/code/trunk/java/client/org/apache/derby/client/am: ClientPreparedStatement.java ClientStatement.java
Date Fri, 03 May 2013 04:08:42 GMT
Author: dag
Date: Fri May  3 04:08:41 2013
New Revision: 1478641

URL: http://svn.apache.org/r1478641
Log:
DERBY-6125 Code clean up in client driver.

    Patch "derby-6125-visibility-03-a" to limit sharing of state
    between classes not in the same package by cloning arrays not
    considered performance sensitive.

    * ClientStatement
      made indexOfCurrentResultSet private by adding accessors

      removed unused field numInvisibleRS

      cloned execute, executeLargeUpdate and executeUpdate's overloads
      input arrays columnIndexes and columnNames

      cloned completeExecuteCall's argument resultSets

    * ClientPreparedStatement

      use new accessor resetResultSetList instead of accessing
      ClientStatement#indexOfCurrentResultSet directly

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientStatement.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement.java?rev=1478641&r1=1478640&r2=1478641&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientPreparedStatement.java
Fri May  3 04:08:41 2013
@@ -2255,7 +2255,7 @@ public class ClientPreparedStatement ext
 
 
         if (sqlMode_ == isQuery__) {
-            indexOfCurrentResultSet_ = -1; //reset ResultSetList
+            resetResultSetList();
             resultSetList_ = new ClientResultSet[batchSize];
         }
 

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientStatement.java?rev=1478641&r1=1478640&r2=1478641&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientStatement.java Fri May
 3 04:08:41 2013
@@ -29,6 +29,7 @@ import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
+import java.util.List;
 import java.util.StringTokenizer;
 import org.apache.derby.shared.common.reference.SQLState;
 import org.apache.derby.shared.common.sanity.SanityManager;
@@ -150,8 +151,7 @@ public class ClientStatement implements 
     boolean openOnServer_ = false;
 
 
-    //private int indexOfCurrentResultSet_ = -1;
-    protected int indexOfCurrentResultSet_ = -1;
+    private int indexOfCurrentResultSet_ = -1;
     ClientResultSet[] resultSetList_ = null;   // array of ResultSet objects
 
     protected final static String TIMEOUT_STATEMENT = "SET STATEMENT_TIMEOUT ";
@@ -194,9 +194,6 @@ public class ClientStatement implements 
     // Used for callable statement OUT paramters.
     Cursor singletonRowData_ = null;
 
-    // number of invisible result sets returned from a stored procedure.
-    private int numInvisibleRS_ = 0;
-
     // This is a cache of the attributes to be sent on prepare.
     // Think about caching the entire prepare DDM string for the re-prepares
     public String cursorAttributesToSendOnPrepare_ = null;
@@ -277,7 +274,6 @@ public class ClientStatement implements 
 
         batch_.clear();
         singletonRowData_ = null;
-        numInvisibleRS_ = 0;
         preparedStatementForAutoGeneratedKeys_ = null;
         generatedKeysResultSet_ = null;
         generatedKeysColumnNames_ = null;
@@ -1357,14 +1353,13 @@ public class ClientStatement implements 
             }
             resultIsResultSet = false;
         } else {
-            if (numInvisibleRS_ == 0 &&
-                    current == CLOSE_CURRENT_RESULT &&
+            if (current == CLOSE_CURRENT_RESULT &&
                     resultSetList_[indexOfCurrentResultSet_] != null) {
                 resultSetList_[indexOfCurrentResultSet_].closeX();
             }
             resultIsResultSet = indexOfCurrentResultSet_ + 1 < resultSetList_.length;
         }
-        if ((current == CLOSE_ALL_RESULTS) && (numInvisibleRS_ == 0)) {
+        if (current == CLOSE_ALL_RESULTS) {
             int numberOfResultSetsToClose = (resultSetList_ == null) ? 0 : indexOfCurrentResultSet_
+ 1;
             boolean willTickleServer = willTickleServer(numberOfResultSetsToClose, false);
             if (willTickleServer) {
@@ -1450,9 +1445,14 @@ public class ClientStatement implements 
                 if (agent_.loggingEnabled()) {
                     agent_.logWriter_.traceEntry(this, "executeUpdate", sql, columnIndexes);
                 }
-                if (columnIndexes != null && columnIndexes.length > 0)
+
+                if (columnIndexes != null && columnIndexes.length > 0) {
                     autoGeneratedKeys_ = ClientStatement.RETURN_GENERATED_KEYS;
-                generatedKeysColumnIndexes_ = columnIndexes;
+                    generatedKeysColumnIndexes_ = columnIndexes.clone();
+                } else {
+                    generatedKeysColumnIndexes_ = null;
+                }
+
                 int updateValue = (int) executeUpdateX(sql);
                 if (agent_.loggingEnabled()) {
                     agent_.logWriter_.traceExit(this, "executeUpdate", updateValue);
@@ -1474,9 +1474,14 @@ public class ClientStatement implements 
                 if (agent_.loggingEnabled()) {
                     agent_.logWriter_.traceEntry(this, "executeLargeUpdate", sql, columnIndexes);
                 }
-                if (columnIndexes != null && columnIndexes.length > 0)
+
+                if (columnIndexes != null && columnIndexes.length > 0) {
                     autoGeneratedKeys_ = ClientStatement.RETURN_GENERATED_KEYS;
-                generatedKeysColumnIndexes_ = columnIndexes;
+                    generatedKeysColumnIndexes_ = columnIndexes.clone();
+                } else {
+                    generatedKeysColumnIndexes_ = null;
+                }
+
                 long updateValue = executeUpdateX(sql);
                 if (agent_.loggingEnabled()) {
                     agent_.logWriter_.traceExit(this, "executeLargeUpdate", updateValue);
@@ -1497,9 +1502,14 @@ public class ClientStatement implements 
                 if (agent_.loggingEnabled()) {
                     agent_.logWriter_.traceEntry(this, "executeUpdate", sql, columnNames);
                 }
-                if (columnNames != null && columnNames.length > 0)
+
+                if (columnNames != null && columnNames.length > 0) {
                     autoGeneratedKeys_ = ClientStatement.RETURN_GENERATED_KEYS;
-                generatedKeysColumnNames_ = columnNames;
+                    generatedKeysColumnNames_ = columnNames.clone();
+                } else {
+                    generatedKeysColumnNames_ = null;
+                }
+
                 int updateValue = (int) executeUpdateX(sql);
                 if (agent_.loggingEnabled()) {
                     agent_.logWriter_.traceExit(this, "executeUpdate", updateValue);
@@ -1521,9 +1531,14 @@ public class ClientStatement implements 
                 if (agent_.loggingEnabled()) {
                     agent_.logWriter_.traceEntry(this, "executeLargeUpdate", sql, columnNames);
                 }
-                if (columnNames != null && columnNames.length > 0)
+
+                if (columnNames != null && columnNames.length > 0) {
                     autoGeneratedKeys_ = ClientStatement.RETURN_GENERATED_KEYS;
-                generatedKeysColumnNames_ = columnNames;
+                    generatedKeysColumnNames_ = columnNames.clone();
+                } else {
+                    generatedKeysColumnIndexes_ = null;
+                }
+
                 long updateValue = executeUpdateX(sql);
                 if (agent_.loggingEnabled()) {
                     agent_.logWriter_.traceExit(this, "executeLargeUpdate", updateValue);
@@ -1565,9 +1580,14 @@ public class ClientStatement implements 
                 if (agent_.loggingEnabled()) {
                     agent_.logWriter_.traceEntry(this, "execute", sql, columnIndexes);
                 }             
-                if (columnIndexes != null && columnIndexes.length > 0)
+
+                if (columnIndexes != null && columnIndexes.length > 0) {
                     autoGeneratedKeys_ = ClientStatement.RETURN_GENERATED_KEYS;
-                generatedKeysColumnIndexes_ = columnIndexes;
+                    generatedKeysColumnIndexes_ = columnIndexes.clone();
+                } else {
+                    generatedKeysColumnIndexes_ = null;
+                }
+
                 boolean b = executeX(sql);
                 if (agent_.loggingEnabled()) {
                     agent_.logWriter_.traceExit(this, "execute", b);
@@ -1588,9 +1608,14 @@ public class ClientStatement implements 
                 if (agent_.loggingEnabled()) {
                     agent_.logWriter_.traceEntry(this, "execute", sql, columnNames);
                 }
-                if (columnNames != null && columnNames.length > 0)
+
+                if (columnNames != null && columnNames.length > 0) {
                     autoGeneratedKeys_ = ClientStatement.RETURN_GENERATED_KEYS;
-                generatedKeysColumnNames_ = columnNames;
+                    generatedKeysColumnNames_ = columnNames.clone();
+                } else {
+                    generatedKeysColumnNames_ = null;
+                }
+
                 boolean b = executeX(sql);
                 if (agent_.loggingEnabled()) {
                     agent_.logWriter_.traceExit(this, "execute", b);
@@ -1815,7 +1840,7 @@ public class ClientStatement implements 
             Cursor singletonParams,
             ClientResultSet[] resultSets) {
         completeExecuteCall(sqlca, singletonParams);
-        resultSetList_ = resultSets;
+        resultSetList_ = resultSets.clone();
         if (resultSets != null) {
             resultSet_ = resultSets[0];
         }
@@ -3312,4 +3337,8 @@ public class ClientStatement implements 
     {
         return ( (rs != null) && (!rs.isClosed()) );
     }
+
+    void resetResultSetList() {
+        indexOfCurrentResultSet_ = -1; //reset ResultSetList
+    }
 }



Mime
View raw message