db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1061977 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ResultSet.java client/org/apache/derby/client/am/Statement.java testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementJdbc20Test.java
Date Fri, 21 Jan 2011 19:31:02 GMT
Author: rhillegas
Date: Fri Jan 21 19:31:01 2011
New Revision: 1061977

URL: http://svn.apache.org/viewvc?rev=1061977&view=rev
Log:
DERBY-4869: Wire network ResultSet for generated keys into the machinery for Statement.closeOnCompletion().

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Statement.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementJdbc20Test.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java?rev=1061977&r1=1061976&r2=1061977&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ResultSet.java Fri Jan 21 19:31:01
2011
@@ -39,6 +39,7 @@ public abstract class ResultSet implemen
     //---------------------navigational members-----------------------------------
 
     public Statement statement_;
+    Statement outerStatement_; // for auto-generated keys
     public ColumnMetaData resultSetMetaData_; // As obtained from the SQLDA
     private SqlWarning warnings_;
     public Cursor cursor_;
@@ -461,6 +462,8 @@ public abstract class ResultSet implemen
         }
 
         statement_.closeMeOnCompletion();
+        if ( (outerStatement_ != null) && (outerStatement_ != statement_) ) { outerStatement_.closeMeOnCompletion();
}
+        outerStatement_ = null;
 
         nullDataForGC();
     }

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=1061977&r1=1061976&r2=1061977&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 Fri Jan 21 19:31:01
2011
@@ -2138,6 +2138,7 @@ public class Statement implements java.s
                     preparedStatementForAutoGeneratedKeys_.readOpenQuery();
                     generatedKeysResultSet_ = preparedStatementForAutoGeneratedKeys_.resultSet_;
                     preparedStatementForAutoGeneratedKeys_.resultSet_ = null;
+                    generatedKeysResultSet_.outerStatement_ = this;
                 }
 
                 if (connection_.autoCommit_) {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementJdbc20Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementJdbc20Test.java?rev=1061977&r1=1061976&r2=1061977&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementJdbc20Test.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementJdbc20Test.java
Fri Jan 21 19:31:01 2011
@@ -100,6 +100,8 @@ public class StatementJdbc20Test extends
                      StatementJdbc20Test.class.getName() + ".dynamicResults' " +
                      "dynamic result sets 2"
                      );
+
+                stmt.execute( "create table t_autogen( a int generated always as identity,
b int )" );
             }
         };
     }
@@ -316,6 +318,7 @@ public class StatementJdbc20Test extends
         vetClosedSelect( closeOnCompletion, delayClosureCall );
         vetClosedCall( closeOnCompletion, delayClosureCall );
         vetClosedPS( closeOnCompletion, delayClosureCall );
+        vetClosedAutoGen( closeOnCompletion, delayClosureCall );
     }
     private void vetClosedSelect( boolean closeOnCompletion, boolean delayClosureCall ) throws
Exception
     {
@@ -398,6 +401,33 @@ public class StatementJdbc20Test extends
 
         if ( !wrapper.isClosed() ) { ps.close(); }
     }
+    private void vetClosedAutoGen( boolean closeOnCompletion, boolean delayClosureCall )
throws Exception
+    {
+        Statement stmt = createStatement();
+        ResultSet rs;
+
+        println( "Verifying AUTOGENERATED KEYS wrapper on " + stmt.getClass().getName() +
+                 " with closeOnCompletion = " + closeOnCompletion +
+                 " and delayClosureCall = " + delayClosureCall );
+        Wrapper41Statement  wrapper = new Wrapper41Statement( stmt );
+
+        if ( !delayClosureCall )
+        { setCloseOnCompletion( wrapper, closeOnCompletion ); }
+
+        stmt.executeUpdate( "insert into t_autogen( b ) values ( 1 )", Statement.RETURN_GENERATED_KEYS
);
+        rs = stmt.getGeneratedKeys();
+
+        if ( delayClosureCall )
+        { setCloseOnCompletion( wrapper, closeOnCompletion ); }
+
+        assertFalse( wrapper.isClosed() );
+
+        rs.close();
+
+        assertEquals( closeOnCompletion, wrapper.isClosed() );
+
+        vetSuccessfulClosure( wrapper, closeOnCompletion );
+    }
     
     private void    setCloseOnCompletion( Wrapper41Statement wrapper, boolean closeOnCompletion
)
         throws Exception



Mime
View raw message