db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1553269 - in /db/derby/code/trunk/java: engine/org/apache/derby/vti/ForeignTableVTI.java testing/org/apache/derbyTesting/functionTests/tests/lang/OptionalToolsTest.java tools/org/apache/derby/impl/tools/optional/ForeignDBViews.java
Date Tue, 24 Dec 2013 13:09:05 GMT
Author: rhillegas
Date: Tue Dec 24 13:09:05 2013
New Revision: 1553269

URL: http://svn.apache.org/r1553269
Log:
DERBY-6440: Drop connection to foreign database when foreignViews optional tool is unloaded.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/vti/ForeignTableVTI.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OptionalToolsTest.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/optional/ForeignDBViews.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/vti/ForeignTableVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/vti/ForeignTableVTI.java?rev=1553269&r1=1553268&r2=1553269&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/vti/ForeignTableVTI.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/vti/ForeignTableVTI.java Tue Dec 24 13:09:05
2013
@@ -194,6 +194,34 @@ public	class   ForeignTableVTI extends V
 
     ////////////////////////////////////////////////////////////////////////
     //
+    //	SUPPORT FUNCTIONS
+    //
+    ////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Remove the cached connection to the foreign database. This method is called
+     * by ForeignDBViews.unloadTool().
+     * </p>
+     */
+    public  static  void    dropConnection( String connectionURL )
+    {
+        _connections.remove( connectionURL );
+    }
+
+    /**
+     * <p>
+     * This function is useful for verifying that the connection to the foreign
+     * database was dropped when the foreignViews tool was unloaded.
+     * </p>
+     */
+    public  static  int countConnections()
+    {
+        return _connections.size();
+    }
+
+    ////////////////////////////////////////////////////////////////////////
+    //
     //	ResultSet BEHAVIOR
     //
     ////////////////////////////////////////////////////////////////////////

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OptionalToolsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OptionalToolsTest.java?rev=1553269&r1=1553268&r2=1553269&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OptionalToolsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OptionalToolsTest.java
Tue Dec 24 13:09:05 2013
@@ -249,6 +249,16 @@ public class OptionalToolsTest  extends 
                 { "Polaris", "100", "1" },
             };
 
+        // create a function to count the number of connections
+        // managed by ForeignTableVTI
+        goodStatement
+            (
+             dboConnection,
+             "create function countConnections() returns int\n" +
+             "language java parameter style java no sql\n" +
+             "external name 'org.apache.derby.vti.ForeignTableVTI.countConnections'\n"
+             );
+
         // wrong number of arguments
         expectExecutionError
             (
@@ -293,6 +303,13 @@ public class OptionalToolsTest  extends 
              starResult,
              false
              );
+        assertResults
+            (
+             dboConnection,
+             "values countConnections()",
+             new String[][] { { "1" } },
+             false
+             );
         
         // wrong number of arguments
         expectExecutionError
@@ -308,6 +325,13 @@ public class OptionalToolsTest  extends 
              dboConnection,
              "call syscs_util.syscs_register_tool( 'foreignViews', false, '" + foreignURL
+ "' )"
              );
+        assertResults
+            (
+             dboConnection,
+             "values countConnections()",
+             new String[][] { { "0" } },
+             false
+             );
 
         // should fail because the view and its schema were dropped when the tool was unloaded
         expectCompilationError
@@ -373,6 +397,14 @@ public class OptionalToolsTest  extends 
              MISSING_SCHEMA,
              starSelect
              );
+        assertResults
+            (
+             dboConnection,
+             "values countConnections()",
+             new String[][] { { "0" } },
+             false
+             );
+        goodStatement( dboConnection, "drop function countConnections" );
     }
 
     /**

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/optional/ForeignDBViews.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/optional/ForeignDBViews.java?rev=1553269&r1=1553268&r2=1553269&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/optional/ForeignDBViews.java
(original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/optional/ForeignDBViews.java
Tue Dec 24 13:09:05 2013
@@ -34,6 +34,7 @@ import org.apache.derby.iapi.sql.diction
 import org.apache.derby.iapi.tools.i18n.LocalizedResource;
 import org.apache.derby.iapi.util.IdUtil;
 import org.apache.derby.iapi.util.StringUtil;
+import org.apache.derby.vti.ForeignTableVTI;
 
 /**
  * <p>
@@ -171,6 +172,9 @@ public	class   ForeignDBViews  implement
 
         // now drop the schemas created by loadTool()
         for ( String schemaName : schemas ) { dropDerbySchema( derbyConn, schemaName ); }
+
+        // now drop the connection to the foreign database
+        ForeignTableVTI.dropConnection( foreignConnectionURL );
     }
 
     ///////////////////////////////////////////////////////////////////////////////////



Mime
View raw message