Author: djd Date: Wed Dec 5 08:10:46 2007 New Revision: 601386 URL: http://svn.apache.org/viewvc?rev=601386&view=rev Log: DERBY-3247 Mark the activations for dynamic result sets as single use once they are returned to the applications JDBC statement. Ensures that the close of the ResultSet will close the activation. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?rev=601386&r1=601385&r2=601386&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Wed Dec 5 08:10:46 2007 @@ -127,7 +127,8 @@ /** This activation is set by EmbedStatement for a single execution Activation. Ie. - a ResultSet from a Statement.executeQuery(). + a ResultSet from a Statement.executeQuery() or + a ResultSet that is now a dynamic result set. In this case the closing of this ResultSet will close the activation or the finalization of the parent EmbedStatement without it being closed will mark the Activation as unused. @@ -4397,6 +4398,16 @@ this.owningStmt = owningStmt; this.localConn = owningStmt.getEmbedConnection(); + + // The activation that created these results now becomes + // a single use activation so it will be closed when this + // object is closed. Otherwise the activation would + // only be closed on garbage collection for any + // dynamic result set created by a PreparedStatement + // or CallableStatement. Dynamic result sets created + // by Statement objects will already be marked as + // single use. + this.singleUseActivation = theResults.getActivation(); } /* Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java?rev=601386&r1=601385&r2=601386&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java Wed Dec 5 08:10:46 2007 @@ -326,6 +326,12 @@ * well, even though prepared statements reuse activations, since * getGeneratedKeys() uses a single-use activation regardless * of statement type. + *
+ * Dynamic result sets (those in dynamicResults array) need not + * be handled here as they will be handled by the statement object + * that created them. In some cases results will point to a + * ResultSet in dynamicResults but all that will happen is that + * the activation will get marked as unused twice. */ protected void finalize() throws Throwable { super.finalize();