db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1055181 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/services/loader/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Tue, 04 Jan 2011 21:19:50 GMT
Author: rhillegas
Date: Tue Jan  4 21:19:48 2011
New Revision: 1055181

URL: http://svn.apache.org/viewvc?rev=1055181&view=rev
Log:
DERBY-4958: Allow wrapper types as output args in the Java signatures of procedures.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignaturesTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java?rev=1055181&r1=1055180&r2=1055181&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java
Tue Jan  4 21:19:48 2011
@@ -953,6 +953,14 @@ nextMethod:	for (int i = 0; i < methods.
         //
         if ( fromClass.getName().equals( toClass.getName() ) ) { return true; }
 
+        //
+        // OUT and INOUT args are arrays. Compare the cell types rather than the array types.
+        //
+        if ( fromClass.isArray() && toClass.isArray() )
+        {
+            return classConvertableFromTo( fromClass.getComponentType(), toClass.getComponentType(),
mixTypes );
+        }
+
 		// When comparing two candidate methods to see which one is closer,
 		// we want to mix object type and primitive type, because they could
 		// both be chosen in the second pass.  But when deciding if a method

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java?rev=1055181&r1=1055180&r2=1055181&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java
Tue Jan  4 21:19:48 2011
@@ -1377,4 +1377,29 @@ public  class   AnsiSignatures
     public  static  String  varchar_Clob_Clob( String a ) { return "-1"; }
     public  static  String  varchar_Clob_Clob( Object a ) { return "-1"; }
 
+
+    //
+    // Procedure with OUT parameters of wrapper type
+    //
+    public  static  void    wrapperProc
+        (
+         Long[] bigintarg,
+         Boolean[] booleanarg,
+         Double[] doublearg,
+         Double[] floatarg,
+         Integer[] intarg,
+         Float[] realarg,
+         Integer[] smallintarg
+         )
+    {
+        bigintarg[ 0 ] = new Long( 1L );
+        booleanarg[ 0 ] = Boolean.TRUE;
+        doublearg[ 0 ] = new Double( 1.0 );
+        floatarg[ 0 ] = new Double( 1.0 );
+        intarg[ 0 ] = new Integer( 1 );
+        realarg[ 0 ] = new Float( 1.0F );
+        smallintarg[ 0 ] = new Integer( 1 );
+    }
+
+        
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignaturesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignaturesTest.java?rev=1055181&r1=1055180&r2=1055181&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignaturesTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignaturesTest.java
Tue Jan  4 21:19:48 2011
@@ -24,12 +24,14 @@ package org.apache.derbyTesting.function
 import java.sql.SQLException;
 import java.sql.SQLWarning;
 import java.sql.Blob;
+import java.sql.CallableStatement;
 import java.sql.Clob;
 import java.sql.Connection;
 import java.sql.Statement;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.DriverManager;
+import java.sql.Types;
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
@@ -730,6 +732,60 @@ public class AnsiSignaturesTest extends 
         
     ///////////////////////////////////////////////////////////////////////////////////
     //
+    // PRODEDURES
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public  void    test_wrapperOutputArgs()
+        throws Exception
+    {
+        Connection  conn = getConnection();
+        PreparedStatement   ps = conn.prepareStatement
+            (
+             "create procedure wrapperProc\n" +
+             "(\n" +
+             "    out bigintCol bigint,\n" +
+             "    out booleanCol boolean,\n" +
+             "    out doubleCol double,\n" +
+             "    out floatCol float,\n" +
+             "    out intCol int,\n" +
+             "    out realCol real,\n" +
+             "    out smallintCol smallint\n" +
+             ")\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "no sql\n" +
+             "external name 'org.apache.derbyTesting.functionTests.tests.lang.AnsiSignatures.wrapperProc'\n"
+             );
+        ps.execute();
+        ps.close();
+
+        CallableStatement cs = conn.prepareCall
+            (
+             "call wrapperProc(  ?, ?, ?, ?, ?, ?, ? )"
+             );
+        int param = 1;
+        cs.registerOutParameter( param++, Types.BIGINT );
+        cs.registerOutParameter( param++, Types.BOOLEAN );
+        cs.registerOutParameter( param++, Types.DOUBLE );
+        cs.registerOutParameter( param++, Types.FLOAT );
+        cs.registerOutParameter( param++, Types.INTEGER );
+        cs.registerOutParameter( param++, Types.REAL );
+        cs.registerOutParameter( param++, Types.SMALLINT );
+
+        cs.execute();
+        param = 1;
+        assertEquals( 1L, cs.getLong( param++ ) );
+        assertEquals( true, cs.getBoolean( param++ ) );
+        assertEquals( 1.0, cs.getDouble( param++ ), 0.0 );
+        assertEquals( 1.0, cs.getDouble( param++ ), 0.0 );
+        assertEquals( 1, cs.getInt( param++ ) );
+        assertEquals( 1.0F, cs.getFloat( param++ ), 0.0F );
+        assertEquals( (short) 1, cs.getShort( param++ ) );
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
     // MINIONS
     //
     ///////////////////////////////////////////////////////////////////////////////////



Mime
View raw message