Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-3390

SQLException thrown from user function kills network connection

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.1.3.1, 10.2.1.6, 10.2.2.0, 10.3.1.4, 10.3.2.1
    • Fix Version/s: 10.5.1.1
    • Component/s: Network Server
    • Labels:
      None
    • Issue & fix info:
      High Value Fix

      Description

      Thanks to Frank Griffin for pointing out this issue in a derby-dev email thread: http://www.nabble.com/SQLException-thrown-from-Table-Function-ResultSet-to15241332.html#a15241332

      If a user-coded function throws a SQLException, Derby will try to cast the exception to a Derby exception class before shipping the exception to the network client. This raises a ClassCastException and kills the connection. I have observed this in 10.4, 10.3, 10.2, and 10.1. You can reproduce this problem with the following function class and sql script.

      The function class:

      import java.sql.*;

      public class BadFunction
      {
      /**

      • <p>
      • This function just throws a SQLException.
      • </p>
        */
        public static int badFunction()
        throws SQLException { throw new SQLException( "I refuse to return an int!" ); }

      }

      Here is the SQL script:

      connect 'jdbc:derby://localhost:8246/derby10.4';

      drop function badFunction;

      create function badFunction()
      returns int
      language java
      parameter style java
      no sql
      external name 'BadFunction.badFunction'
      ;

      values ( badFunction() );

      values ( badFunction() );

        Attachments

        1. DERBY-3390_a.diff
          0.9 kB
          Myrna van Lunteren
        2. DERBY-3390_b.diff
          2 kB
          Myrna van Lunteren
        3. DERBY-3390_c.diff
          11 kB
          Myrna van Lunteren

          Activity

            People

            • Assignee:
              myrna Myrna van Lunteren
              Reporter:
              rhillegas Richard N. Hillegas

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment