db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r964039 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
Date Wed, 14 Jul 2010 13:10:55 GMT
Author: rhillegas
Date: Wed Jul 14 13:10:55 2010
New Revision: 964039

URL: http://svn.apache.org/viewvc?rev=964039&view=rev
Log:
DERBY-4459: Eliminate optimization which caused verification error in nested function calls.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java?rev=964039&r1=964038&r2=964039&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
Wed Jul 14 13:10:55 2010
@@ -373,6 +373,12 @@ public class StaticMethodCallNode extend
 		int		count = methodParms.length;
 		for (int parm = 0; parm < count; parm++)
 		{
+            //
+            // We also skip the optimization if the argument must be cast to a primitive.
In this case we need
+            // a runtime check to make sure that the argument is not null. See DERBY-4459.
+            //
+            if ( (methodParms != null) && methodParms[ parm ].mustCastToPrimitive()
) { continue; }
+            
 			if (methodParms[parm] instanceof SQLToJavaValueNode &&
 				((SQLToJavaValueNode)methodParms[parm]).getSQLValueNode() instanceof
 				JavaToSQLValueNode)

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java?rev=964039&r1=964038&r2=964039&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
Wed Jul 14 13:10:55 2010
@@ -45,6 +45,8 @@ import org.apache.derbyTesting.junit.JDB
  */
 public class RoutineTest extends BaseJDBCTestCase {
 
+    private static final String CANNOT_STUFF_NULL_INTO_PRIMITIVE = "39004";
+    
     public RoutineTest(String name)
     {
         super(name);
@@ -616,6 +618,29 @@ public class RoutineTest extends BaseJDB
     	
     }
     
+    /**
+     * Test that we don't get verification errors trying to cram nulls
+     * into primitive args. See DERBY-4459.
+     */
+    public void test_4459() throws Exception
+    {
+    	Statement s = createStatement();
+
+    	s.executeUpdate
+            (
+             "create function getNullInt() returns int language java parameter style java\n"
+
+             "external name '" + RoutineTest.class.getName() + ".getNullInt'"
+             );
+    	s.executeUpdate
+            (
+             "create function negateInt( a int ) returns int language java parameter style
java\n" +
+             "external name '" + RoutineTest.class.getName() + ".negateInt'"
+             );
+
+        assertStatementError( CANNOT_STUFF_NULL_INTO_PRIMITIVE, s, "values( negateInt( cast(
null as int) ) )" );
+        assertStatementError( CANNOT_STUFF_NULL_INTO_PRIMITIVE, s, "values( negateInt( getNullInt()
) )" );
+    }
+    
     /*
     ** Routine implementations called from the tests but do
     *  not use DriverManager so that this test can be used on
@@ -661,5 +686,8 @@ public class RoutineTest extends BaseJDB
            return count;
        }
 
+    public static int negateInt( int arg ) { return -arg; }
+    public static Integer getNullInt() { return null; }
+    
 }
 



Mime
View raw message