db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1070897 - in /db/derby/code/branches/10.6: ./ java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
Date Tue, 15 Feb 2011 13:52:49 GMT
Author: kmarsden
Date: Tue Feb 15 13:52:49 2011
New Revision: 1070897

URL: http://svn.apache.org/viewvc?rev=1070897&view=rev
Log:
DERBY-4459 Verification error at execute-time when an outer function which takes a primitive
arg is wrapped around an inner function which returns the corresponding Java wrapper object

merge 964039 from trunk.  
Contributed by Rick Hillegas


Modified:
    db/derby/code/branches/10.6/   (props changed)
    db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java

Propchange: db/derby/code/branches/10.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 15 13:52:49 2011
@@ -1,2 +1,2 @@
-/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,961892,962716,963206,963705,964115,964402,965647,967304,980089,980684,986689,986834,987539,989099,990292,997325,998170,999119,999479,1002291,1002682,1002853,1021426,1025795,1028716,1030043,1033485,1033864,1038514,1040658,1053724,1055169,1062096,1063809,1065061,1067250
+/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,961892,962716,963206,963705,964039,964115,964402,965647,967304,980089,980684,986689,986834,987539,989099,990292,997325,998170,999119,999479,1002291,1002682,1002853,1021426,1025795,1028716,1030043,1033485,1033864,1038514,1040658,1053724,1055169,1062096,1063809,1065061,1067250
 /db/derby/docs/trunk:954344

Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java?rev=1070897&r1=1070896&r2=1070897&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
(original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
Tue Feb 15 13:52:49 2011
@@ -369,6 +369,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/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java?rev=1070897&r1=1070896&r2=1070897&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
Tue Feb 15 13:52:49 2011
@@ -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