db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r672749 - in /db/derby/code/branches/10.4/java/client/org/apache/derby/client: ClientPooledConnection.java am/Connection.java net/NetConnection.java
Date Mon, 30 Jun 2008 12:36:36 GMT
Author: kristwaa
Date: Mon Jun 30 05:36:36 2008
New Revision: 672749

URL: http://svn.apache.org/viewvc?rev=672749&view=rev
Log:
DERBY-3581 / DERBY-3723: Backports.
Merged revisions 667568 and 671128 from trunk.
The former is a code clean up patch, the latter a change of behavior in the same area of the
code. The variable holding the current schema in the client driver is now reset to the user
name when a new logical connection is created.

Modified:
    db/derby/code/branches/10.4/java/client/org/apache/derby/client/ClientPooledConnection.java
    db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Connection.java
    db/derby/code/branches/10.4/java/client/org/apache/derby/client/net/NetConnection.java

Modified: db/derby/code/branches/10.4/java/client/org/apache/derby/client/ClientPooledConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/client/org/apache/derby/client/ClientPooledConnection.java?rev=672749&r1=672748&r2=672749&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/client/org/apache/derby/client/ClientPooledConnection.java
(original)
+++ db/derby/code/branches/10.4/java/client/org/apache/derby/client/ClientPooledConnection.java
Mon Jun 30 05:36:36 2008
@@ -242,7 +242,7 @@
             	// to reset the connection state to the default on 
             	// PooledConnection.getConnection() otherwise the 
             	// isolation level and holdability was not correct and out of sync with the
server.
-                physicalConnection_.reset(logWriter_, true);
+                physicalConnection_.reset(logWriter_);
             }
             else {
                 physicalConnection_.lightReset();    //poolfix

Modified: db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Connection.java?rev=672749&r1=672748&r2=672749&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Connection.java Mon
Jun 30 05:36:36 2008
@@ -61,7 +61,7 @@
     // ------------------------properties set for life of connection--------------
 
     // See ClientDataSource pre-connect settings
-    public transient String user_;
+    protected final String user_;
     public boolean retrieveMessageText_;
     protected boolean jdbcReadOnly_;
     /**
@@ -171,7 +171,8 @@
                          String password,
                          org.apache.derby.jdbc.ClientBaseDataSource dataSource) 
                                                            throws SqlException {
-        initConnection(logWriter, user, dataSource);
+        this.user_ = user;
+        initConnection(logWriter, dataSource);
     }
 
     protected Connection(org.apache.derby.client.am.LogWriter logWriter,
@@ -180,21 +181,19 @@
                          boolean isXAConn,
                          org.apache.derby.jdbc.ClientBaseDataSource dataSource) 
                                                            throws SqlException {
+        this.user_ = user;
         isXAConnection_ = isXAConn;
-        initConnection(logWriter, user, dataSource);
+        initConnection(logWriter, dataSource);
     }
 
     // For jdbc 2 connections
     protected void initConnection(org.apache.derby.client.am.LogWriter logWriter,
-                                  String user,
                                   org.apache.derby.jdbc.ClientBaseDataSource
                                             dataSource) throws SqlException {
         if (logWriter != null) {
             logWriter.traceConnectEntry(dataSource);
         }
 
-        user_ = user;
-
         // Extract common properties.
         // Derby-409 fix - Append connectionAttributes only if it is non-null. 
         // DERBY-1130 - Append connectionAttributes only if database name is
@@ -270,30 +269,24 @@
     }
 
     // This is a callback method, called by subsystem - NetConnection
-    protected void resetConnection(LogWriter logWriter,
-                                   boolean recomputeFromDataSource) throws SqlException {
+    protected void resetConnection(LogWriter logWriter)
+            throws SqlException {
         // Transaction isolation level is handled in completeReset.
         // clearWarningsX() will re-initialize the following properties
         clearWarningsX();
 
-        if (recomputeFromDataSource) { // no need to reinitialize connection state if ds
hasn't changed
-            // property encryptionManager_
-            // if needed this will later be initialized by NET calls to initializePublicKeyForEncryption()
-            encryptionManager_ = null;
-
-            // property: open_
-            // this should already be true
-
-            currentSchemaName_ = null;
-            autoCommit_ = true;
-            inUnitOfWork_ = false;
-            holdability = ResultSet.HOLD_CURSORS_OVER_COMMIT;
-        }
+        // property encryptionManager_
+        // if needed this will later be initialized by NET calls to initializePublicKeyForEncryption()
+        encryptionManager_ = null;
+
+        // DERBY-3723: Reset schema to user name.
+        currentSchemaName_ = this.user_;
+        autoCommit_ = true;
+        inUnitOfWork_ = false;
+        holdability = ResultSet.HOLD_CURSORS_OVER_COMMIT;
 
-        
-        if (recomputeFromDataSource) {
-            this.agent_.resetAgent(this, logWriter, loginTimeout_, serverNameIP_, portNumber_);
-        }
+        this.agent_.resetAgent(
+                this, logWriter, loginTimeout_, serverNameIP_, portNumber_);
     }
 
     // For jdbc 1 connections
@@ -2086,14 +2079,14 @@
     // can this be called in a unit of work
     // can this be called from within a stored procedure
     //
-    synchronized public void reset(LogWriter logWriter, 
-            boolean recomputeFromDataSource) throws SqlException {
+    synchronized public void reset(LogWriter logWriter)
+            throws SqlException {
         if (logWriter != null) {
             logWriter.traceConnectResetEntry(this, logWriter, user_, 
                                              dataSource_);
         }
         try {
-            reset_(logWriter, recomputeFromDataSource);
+            reset_(logWriter);
         } catch (SqlException sqle) {
             DisconnectException de = new DisconnectException(agent_, 
                 new ClientMessageId(SQLState.CONNECTION_FAILED_ON_RESET));
@@ -2110,8 +2103,7 @@
         availableForReuse_ = false;
     }
 
-    abstract protected void reset_(LogWriter logWriter, 
-            boolean recomputerFromDataSource) throws SqlException;
+    abstract protected void reset_(LogWriter logWriter) throws SqlException;
 
     /**
      * <br>NOTE:</br>The following comments are valid for the changes done as
@@ -2122,13 +2114,15 @@
      * forces us to go to the server all the time. Since the value should now
      * be valid (DERBY-3192), we check if it has been changed from the default.
      *
-     * @param recomputeFromDataSource is now used to differentiate between
+     * @param closeStatementsOnClose is used to differentiate between
      *      cases where statement pooling is enabled or not. If {@code true}, it
      *      means statement pooling is disabled and the statements are fully
      *      reset, which includes a re-prepare. If {@code false}, statement
      *      pooling is enabled, and a more lightweight reset procedure is used.
      */
-    protected void completeReset(boolean isDeferredReset, boolean recomputeFromDataSource)
throws SqlException {
+    protected void completeReset(boolean isDeferredReset,
+                                 boolean closeStatementsOnClose)
+            throws SqlException {
         open_ = true;
 
         completeLocalRollback(); // this will close the cursors if the physical connection
hadn't been closed for reuse properly
@@ -2137,14 +2131,14 @@
         // Notice that these physical statements may not belong to this logical connection.
         // Iterate through the physical statements and re-enable them for reuse.
 
-        if (recomputeFromDataSource) {
+        if (closeStatementsOnClose) {
             // NOTE: This is to match previous behavior.
             //       Investigate and check if it is really necessary.
             this.isolation_ = TRANSACTION_UNKNOWN;
             java.util.Set keySet = openStatements_.keySet();
             for (java.util.Iterator i = keySet.iterator(); i.hasNext();) {
                 Object o = i.next();
-                ((Statement) o).reset(recomputeFromDataSource);
+                ((Statement) o).reset(closeStatementsOnClose);
             }
         } else {
             // Must reset transaction isolation level if it has been changed.

Modified: db/derby/code/branches/10.4/java/client/org/apache/derby/client/net/NetConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/client/org/apache/derby/client/net/NetConnection.java?rev=672749&r1=672748&r2=672749&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/client/org/apache/derby/client/net/NetConnection.java
(original)
+++ db/derby/code/branches/10.4/java/client/org/apache/derby/client/net/NetConnection.java
Mon Jun 30 05:36:36 2008
@@ -34,7 +34,6 @@
 import org.apache.derby.client.am.Statement;
 import org.apache.derby.client.am.Utils;
 import org.apache.derby.jdbc.ClientBaseDataSource;
-import org.apache.derby.jdbc.ClientDataSource;
 import org.apache.derby.jdbc.ClientDriver;
 import org.apache.derby.client.ClientPooledConnection;
 
@@ -306,43 +305,40 @@
 
     // preferably without password in the method signature.
     // We can probally get rid of flowReconnect method.
-    public void resetNetConnection(org.apache.derby.client.am.LogWriter logWriter,
-                                   boolean recomputeFromDataSource) throws SqlException {
-        super.resetConnection(logWriter, recomputeFromDataSource);
+    public void resetNetConnection(org.apache.derby.client.am.LogWriter logWriter)
+            throws SqlException {
+        super.resetConnection(logWriter);
         //----------------------------------------------------
-        if (recomputeFromDataSource) {
-            // do not reset managers on a connection reset.  this information shouldn't
-            // change and can be used to check secmec support.
-
-            targetExtnam_ = null;
-            targetSrvclsnm_ = null;
-            targetSrvnam_ = null;
-            targetSrvrlslv_ = null;
-            publicKey_ = null;
-            targetPublicKey_ = null;
-            sourceSeed_ = null;
-            targetSeed_ = null;
-            targetSecmec_ = 0;
-            resetConnectionAtFirstSql_ = false;
+        // do not reset managers on a connection reset.  this information shouldn't
+        // change and can be used to check secmec support.
 
-        }
+        targetExtnam_ = null;
+        targetSrvclsnm_ = null;
+        targetSrvnam_ = null;
+        targetSrvrlslv_ = null;
+        publicKey_ = null;
+        targetPublicKey_ = null;
+        sourceSeed_ = null;
+        targetSeed_ = null;
+        targetSecmec_ = 0;
+        resetConnectionAtFirstSql_ = false;
         // properties prddta_ and crrtkn_ will be initialized by
         // calls to constructPrddta() and constructCrrtkn()
         //----------------------------------------------------------
         boolean isDeferredReset = flowReconnect(getDeferredResetPassword(),
                                                 securityMechanism_);
-        completeReset(isDeferredReset, recomputeFromDataSource);
+        completeReset(isDeferredReset);
     }
 
 
-    protected void reset_(org.apache.derby.client.am.LogWriter logWriter,
-                          boolean recomputeFromDataSource) throws SqlException {
+    protected void reset_(org.apache.derby.client.am.LogWriter logWriter)
+            throws SqlException {
         if (inUnitOfWork_) {
             throw new SqlException(logWriter, 
                 new ClientMessageId(
                     SQLState.NET_CONNECTION_RESET_NOT_ALLOWED_IN_UNIT_OF_WORK));
         }
-        resetNetConnection(logWriter, recomputeFromDataSource);
+        resetNetConnection(logWriter);
     }
 
     java.util.List getSpecialRegisters() {
@@ -363,13 +359,9 @@
         super.completeConnect();
     }
 
-    protected void completeReset(boolean isDeferredReset, boolean recomputeFromDataSource)
throws SqlException {
-        // NB! Override the recomputFromDataSource flag.
-        //     This was done as a temporary, minimal intrusive fix to support
-        //     JDBC statement pooling.
-        //     See DERBY-3341 for details.
-        super.completeReset(isDeferredReset,
-                recomputeFromDataSource && closeStatementsOnClose);
+    protected void completeReset(boolean isDeferredReset)
+            throws SqlException {
+        super.completeReset(isDeferredReset, closeStatementsOnClose);
     }
 
     public void flowConnect(String password,



Mime
View raw message