db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1153478 - in /db/derby/code/branches/10.8/java: engine/org/apache/derby/impl/services/reflect/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Wed, 03 Aug 2011 13:26:37 GMT
Author: rhillegas
Date: Wed Aug  3 13:26:36 2011
New Revision: 1153478

URL: http://svn.apache.org/viewvc?rev=1153478&view=rev
Log:
DERBY-5352: Ported 1153474 from trunk to 10.8 branch.

Modified:
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/services/reflect/JarLoader.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DatabaseClassLoadingTest.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dummy_vti.jar

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/services/reflect/JarLoader.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/services/reflect/JarLoader.java?rev=1153478&r1=1153477&r2=1153478&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/services/reflect/JarLoader.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/services/reflect/JarLoader.java
Wed Aug  3 13:26:36 2011
@@ -175,7 +175,8 @@ final class JarLoader extends SecureClas
         // not make assumptions about this check reducing the
         // number of classes it has to check for.
         if (className.startsWith("org.apache.derby.")
-                && !className.startsWith("org.apache.derby.jdbc."))
+                && !className.startsWith("org.apache.derby.jdbc.")
+                && !className.startsWith("org.apache.derby.vti."))
         {
             ClassNotFoundException cnfe = new ClassNotFoundException(className);
             //cnfe.printStackTrace(System.out);

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DatabaseClassLoadingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DatabaseClassLoadingTest.java?rev=1153478&r1=1153477&r2=1153478&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DatabaseClassLoadingTest.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DatabaseClassLoadingTest.java
Wed Aug  3 13:26:36 2011
@@ -108,6 +108,7 @@ public class DatabaseClassLoadingTest ex
                 "testLoadDerbyClassIndirectly",
                 "testIndirectLoading",
                 "testTableFunctionInJar",
+                "test_5352",
             };
             
             for (int i = 0; i < orderedTests.length; i++)
@@ -1044,7 +1045,7 @@ public class DatabaseClassLoadingTest ex
              "language java\n" +
              "parameter style DERBY_JDBC_RESULT_SET\n" +
              "reads sql data\n" +
-             "external name 'DummyVTI2.dummyVTI'\n"
+             "external name 'MissingClass.dummyVTI'\n"
              );
 
         // invoke the scalar function
@@ -1078,7 +1079,63 @@ public class DatabaseClassLoadingTest ex
         } catch (SQLException e) {
             assertSQLState("XJ001", e);
         }
+
+        // drop the useless function
+        s.executeUpdate( "drop function dummyVTI2\n" );
+
+        setDBClasspath(null);
+        
+        s.close();
+    }
+    
+    /**
+     * Test that restricted table functions can be invoked from inside jar files stored in
+     * the database.
+     */
+    public void test_5352() throws SQLException, MalformedURLException
+    {
+        // skip this test if vm is pre Java 5. This is because the jar file was
+        // compiled by a modern compiler and the jar file won't load on
+        // old vms.
+        if ( JVMInfo.J2ME || (JVMInfo.JDK_ID < JVMInfo.J2SE_15 ) ) { return; }
+        
+        String jarName = "EMC.DUMMY_VTI2";
+
+        installJar("dummy_vti.jar", jarName );
+
+        setDBClasspath( jarName );
+
+        Statement s = createStatement();
+
+        // register the table function
+        s.executeUpdate
+            (
+             "create function dummyVTI2( allowsRestriction boolean )\n" +
+             "returns table( a int )\n" +
+             "language java\n" +
+             "parameter style DERBY_JDBC_RESULT_SET\n" +
+             "no sql\n" +
+             "external name 'DummyVTI2.dummyVTI2'\n"
+             );
         
+        // invoke the table function
+        JDBC.assertFullResultSet
+            (
+                s.executeQuery
+                (
+                 "select * from table( dummyVTI2( true ) ) s where a = 1"
+                 ),
+                new String[][]
+                {
+                    { "1" }
+                }
+             );
+
+        // verify that the RestrictedVTI machinery is really invoked
+        assertStatementError( "XYZZY", s, "select * from table( dummyVTI2( false ) ) s where
a = 1" );
+        
+        s.executeUpdate( "drop function dummyVTI2\n" );
+
         setDBClasspath(null);
         
         s.close();

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dummy_vti.jar
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dummy_vti.jar?rev=1153478&r1=1153477&r2=1153478&view=diff
==============================================================================
Binary files - no diff available.



Mime
View raw message