You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ma...@apache.org on 2008/02/27 05:51:48 UTC

svn commit: r631481 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java

Author: mamta
Date: Tue Feb 26 20:51:47 2008
New Revision: 631481

URL: http://svn.apache.org/viewvc?rev=631481&view=rev
Log:
Checking in code cleanup for DERBY-3304. This code cleanup is based on Knut's review of my
earlier commit 629926. No functionality has changed, but code will be now much easier to
read.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=631481&r1=631480&r2=631481&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java Tue Feb 26 20:51:47 2008
@@ -2742,26 +2742,26 @@
 				continue;
 			}
 
-			ResultSet activationResultSet = null;
-			boolean resultsetReturnsRows = false;
-			if (a.getResultSet() != null) {
-				activationResultSet = a.getResultSet();
-				resultsetReturnsRows = activationResultSet.returnsRows();
-			}
+			//Determine if the activation has a resultset and if that resultset
+			//returns rows. For such an activation, we need to take special
+			//actions during commit and rollback as explained in the comments
+			//below.
+			ResultSet activationResultSet = a.getResultSet();
+			boolean resultsetReturnsRows =  
+				(activationResultSet != null) && activationResultSet.returnsRows(); ;
 
 			if (forRollback) { 
-				if (activationResultSet != null) 
-					if (resultsetReturnsRows)
-						//Since we are dealing with rollback, we need to reset 
-						//the activation no matter what the holdability might 
-						//be provided that resultset returns rows. An example
-						//where we do not want to close a resultset that does
-						//not return rows would be a java procedure which has
-						//user invoked rollback inside of it. That rollback
-						//should not reset the activation associated with
-						//the call to java procedure because that activation
-						//is still being used.
-						a.reset();
+				if (resultsetReturnsRows)
+					//Since we are dealing with rollback, we need to reset 
+					//the activation no matter what the holdability might 
+					//be provided that resultset returns rows. An example
+					//where we do not want to close a resultset that does
+					//not return rows would be a java procedure which has
+					//user invoked rollback inside of it. That rollback
+					//should not reset the activation associated with
+					//the call to java procedure because that activation
+					//is still being used.
+					a.reset();
 				// Only invalidate statements if we performed DDL.
 				if (dataDictionaryInWriteMode()) {
 					ExecPreparedStatement ps = a.getPreparedStatement();
@@ -2771,26 +2771,22 @@
 				}
 			} else {
 				//We are dealing with commit here. 
-				if (activationResultSet != null) {
-					//if the activation has resultset associated with it, then 
-					//use following criteria to take the action
-					if (resultsetReturnsRows){
-						if (a.getResultSetHoldability() == false)
-							//Close result sets that return rows and are not held 
-							//across commit. This is to implement closing JDBC 
-							//result sets that are CLOSE_CURSOR_ON_COMMIT at commit 
-							//time. 
-							activationResultSet.close();
-						else 
-							//Clear the current row of the result sets that return
-							//rows and are held across commit. This is to implement
-							//keeping JDBC result sets open that are 
-							//HOLD_CURSORS_OVER_COMMIT at commit time and marking
-							//the resultset to be not on a valid row position. The 
-							//user will need to reposition within the resultset 
-							//before doing any row operations.
-							activationResultSet.clearCurrentRow();							
-					}
+				if (resultsetReturnsRows){
+					if (a.getResultSetHoldability() == false)
+						//Close result sets that return rows and are not held 
+						//across commit. This is to implement closing JDBC 
+						//result sets that are CLOSE_CURSOR_ON_COMMIT at commit 
+						//time. 
+						activationResultSet.close();
+					else 
+						//Clear the current row of the result sets that return
+						//rows and are held across commit. This is to implement
+						//keeping JDBC result sets open that are 
+						//HOLD_CURSORS_OVER_COMMIT at commit time and marking
+						//the resultset to be not on a valid row position. The 
+						//user will need to reposition within the resultset 
+						//before doing any row operations.
+						activationResultSet.clearCurrentRow();							
 				}
 				a.clearHeapConglomerateController();
 			}