db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1055676 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/EXTDTAInputStream.java testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java
Date Wed, 05 Jan 2011 22:55:09 GMT
Author: rhillegas
Date: Wed Jan  5 22:55:09 2011
New Revision: 1055676

URL: http://svn.apache.org/viewvc?rev=1055676&view=rev
Log:
DERBY-4959: All null LOBs as procedure output args.

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java?rev=1055676&r1=1055675&r2=1055676&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAInputStream.java Wed Jan
 5 22:55:09 2011
@@ -150,9 +150,13 @@ class EXTDTAInputStream extends InputStr
         switch ( ndrdaType )
         {
         case DRDAConstants.DRDA_TYPE_NLOBBYTES:
-            return new EXTDTAInputStream( cs.getBlob( column ), ndrdaType );
+            Blob    blob = cs.getBlob( column );
+            if ( blob ==  null ) { return null; }
+            return new EXTDTAInputStream( blob, ndrdaType );
         case DRDAConstants.DRDA_TYPE_NLOBCMIXED:
-            return new EXTDTAInputStream( cs.getClob( column ), ndrdaType );
+            Clob    clob = cs.getClob( column );
+            if ( clob == null ) { return null; }
+            return new EXTDTAInputStream( clob, ndrdaType );
         default:
             badDRDAType( ndrdaType );
 			return null;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java?rev=1055676&r1=1055675&r2=1055676&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/CallableStatementTest.java
Wed Jan  5 22:55:09 2011
@@ -668,6 +668,73 @@ public class CallableStatementTest  exte
         //
         assertEquals( 22, actualTypeCount );
     }
+
+    /**
+     * <p>
+     * Regression test for https://issues.apache.org/jira/browse/DERBY-4959, an NPE
+     * trying to return null LOBs as procedure output args.
+     * </p>
+     */
+    public  void    test_4959() throws Exception
+    {
+        Connection  conn = getConnection();
+
+        PreparedStatement   ps = prepareStatement
+            (
+             conn,
+             "create procedure blobProc\n" +
+             "(\n" +
+             "    out blobCol blob\n" +
+             ")\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "no sql\n" +
+             "external name 'org.apache.derbyTesting.functionTests.tests.jdbc4.CallableStatementTest.blobProc'\n"
+             );
+        ps.execute();
+        ps.close();
+        ps = prepareStatement
+            (
+             conn,
+             "create procedure clobProc\n" +
+             "(\n" +
+             "    out clobCol clob\n" +
+             ")\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "no sql\n" +
+             "external name 'org.apache.derbyTesting.functionTests.tests.jdbc4.CallableStatementTest.clobProc'\n"
+             );
+        ps.execute();
+        ps.close();
+
+        CallableStatement cs = prepareCall
+            (
+             conn,
+             "call blobProc(  ? )"
+             );
+        cs.registerOutParameter( 1, Types.BLOB );
+        cs.execute();
+        assertNull( cs.getBlob( 1 ) );
+        cs.close();
+        
+        cs = prepareCall
+            (
+             conn,
+             "call clobProc(  ? )"
+             );
+        cs.registerOutParameter( 1, Types.CLOB );
+        cs.execute();
+        assertNull( cs.getClob( 1 ) );
+        cs.close();
+
+        ps = prepareStatement( conn, "drop procedure blobProc" );
+        ps.execute();
+        ps.close();
+        ps = prepareStatement( conn, "drop procedure clobProc" );
+        ps.execute();
+        ps.close();
+    }
     
     /**
      * <p>
@@ -724,6 +791,24 @@ public class CallableStatementTest  exte
         varcharforbitdataarg[0] = BINARY_VALUE;
     }
 
+    public  static  void    blobProc
+        (
+         Blob[] blobarg
+         )
+        throws Exception
+    {
+        blobarg[0] = null;
+    }
+
+    public  static  void    clobProc
+        (
+         Clob[] clobarg
+         )
+        throws Exception
+    {
+        clobarg[0] = null;
+    }
+
     /**
      * Return suite with all tests of the class.
      */



Mime
View raw message