You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2011/02/15 15:52:26 UTC
svn commit: r1070927 - in /db/derby/code/branches/10.5: ./
java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
Author: kmarsden
Date: Tue Feb 15 14:52:26 2011
New Revision: 1070927
URL: http://svn.apache.org/viewvc?rev=1070927&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.5/ (props changed)
db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 15 14:52:26 2011
@@ -1,2 +1,2 @@
/db/derby/code/branches/10.6:942027,957000,962738,965351,987678,997790*,1031623,1055601,1068474
-/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,891350,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,961892,962716,964402,965647,967304,980089,980684,986689,986834,98
7539,989099,997325*,999119,1002291,1002682,1002853,1021426,1025795,1030043,1040658,1053724,1055169,1062096,1063809,1065061,1067250
+/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,891350,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,961892,962716,964039,964402,965647,967304,980089,980684,986689,98
6834,987539,989099,997325*,999119,1002291,1002682,1002853,1021426,1025795,1030043,1040658,1053724,1055169,1062096,1063809,1065061,1067250
Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java?rev=1070927&r1=1070926&r2=1070927&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java Tue Feb 15 14:52:26 2011
@@ -352,6 +352,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.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java?rev=1070927&r1=1070926&r2=1070927&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java Tue Feb 15 14:52:26 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; }
+
}