Derby
  1. Derby
  2. DERBY-6089

CallableStatement#registerOutParameter on client lacks check of legal types.

    Details

    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Deviation from standard

      Description

      Cf the attached negative test in a patch to PreparedStatement42.

      In JDBC 4.2, the Javadoc for registerOutParameter(int parameterIndex,
      int sqlType, String typeName) reads:

      :
      @exception SQLFeatureNotSupportedException if sqlType is a ARRAY,
      BLOB, CLOB, DATALINK, JAVA_OBJECT, NCHAR, NCLOB, NVARCHAR,
      LONGNVARCHAR, REF, ROWID, SQLXML or STRUCT data type and the JDBC
      driver does not support this data type
      :

      For the new overloads, for embedded this is checked inside Util42#getTypeAsInt. The similar
      client method, Utils42#getTypeAsInt does not do this checking.

      1. derby-6089-02-ab-addCheckToOldOverloads.diff
        95 kB
        Rick Hillegas
      2. derby-6089-02-aa-addCheckToOldOverloads.diff
        16 kB
        Rick Hillegas
      3. derby-6089-01-ab-addCheckToClient.diff
        12 kB
        Rick Hillegas
      4. derby-6089-01-aa-addCheckToClient.diff
        12 kB
        Rick Hillegas
      5. 6089-repro-old-overloads.diff
        2 kB
        Dag H. Wanvik
      6. 6089-repro.diff
        1 kB
        Dag H. Wanvik

        Issue Links

          Activity

          Hide
          Dag H. Wanvik added a comment -

          Attaching another repro that shows the behavior of the old overloads: it seems they are missing the type check too, but they behave differently for embedded and client:
          on embedded we see an exception that the datatype is not correct for the parameter number (correct, but I would exoect the SQLFeatureNotSupportedException for the old overloads, too), and for client, no error is thrown in the call to registerOutParameter. So, are both check types missing there?

          Show
          Dag H. Wanvik added a comment - Attaching another repro that shows the behavior of the old overloads: it seems they are missing the type check too, but they behave differently for embedded and client: on embedded we see an exception that the datatype is not correct for the parameter number (correct, but I would exoect the SQLFeatureNotSupportedException for the old overloads, too), and for client, no error is thrown in the call to registerOutParameter. So, are both check types missing there?
          Hide
          Rick Hillegas added a comment -

          Attaching derby-6089-01-aa-addCheckToClient.diff. This patch makes the client perform the same check as the embedded driver for the new CallableStatement.registerOutParameter() overloads. I will run regression tests.

          This patch addresses the first problem described by Dag, the problem with the new overloads. The patch does not address the follow-on pre-existing problem with the old overloads.

          Touches the following files:

          ------------

          M java/client/org/apache/derby/client/am/PreparedStatement.java
          M java/client/org/apache/derby/client/am/Utils42.java
          M java/client/org/apache/derby/client/am/Agent.java

          Factors type checking in the client to mimic the embedded behavior.

          ------------

          M java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java

          Adds Dag's negative case to this test.

          Show
          Rick Hillegas added a comment - Attaching derby-6089-01-aa-addCheckToClient.diff. This patch makes the client perform the same check as the embedded driver for the new CallableStatement.registerOutParameter() overloads. I will run regression tests. This patch addresses the first problem described by Dag, the problem with the new overloads. The patch does not address the follow-on pre-existing problem with the old overloads. Touches the following files: ------------ M java/client/org/apache/derby/client/am/PreparedStatement.java M java/client/org/apache/derby/client/am/Utils42.java M java/client/org/apache/derby/client/am/Agent.java Factors type checking in the client to mimic the embedded behavior. ------------ M java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java Adds Dag's negative case to this test.
          Hide
          Dag H. Wanvik added a comment -

          Thanks, Rick, looks good. I see TINYINT is (only) commented out in the test; intentional or carry-over from my repros?

          Show
          Dag H. Wanvik added a comment - Thanks, Rick, looks good. I see TINYINT is (only) commented out in the test; intentional or carry-over from my repros?
          Hide
          Rick Hillegas added a comment -

          Thanks for the quick review, Dag. Tests passed cleanly for me on the first patch. Attaching derby-6089-01-ab-addCheckToClient.diff, a second rev which removes the commented-out TINYINT line. Committed at subversion revision 1450168.

          Show
          Rick Hillegas added a comment - Thanks for the quick review, Dag. Tests passed cleanly for me on the first patch. Attaching derby-6089-01-ab-addCheckToClient.diff, a second rev which removes the commented-out TINYINT line. Committed at subversion revision 1450168.
          Hide
          Rick Hillegas added a comment -

          Attaching derby-6089-02-aa-addCheckToOldOverloads.diff. This patch makes the old overloads behave like the new overloads: If the jdbc type is not a legal Derby data type, then a SQLFeatureNotSupportedException is raised. I am running tests now.

          Touches the following files:

          --------------

          M java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java

          The guts of the change to the embedded driver: check the data type whenever calling registerOutParameter.

          --------------

          M java/engine/org/apache/derby/impl/jdbc/Util42.java
          M java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement42.java
          M java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement42.java
          M java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java
          M java/engine/org/apache/derby/impl/jdbc/Util.java
          M java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
          M java/engine/org/apache/derby/impl/jdbc/EmbedResultSet42.java

          Some refactoring in order to support the embedded change.

          --------------

          M java/client/org/apache/derby/client/am/CallableStatement.java

          The change to the client driver: check the data type whenever calling registerOutParameter.

          --------------

          M java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java

          Add Dag's test case from 6089-repro-old-overloads.diff.

          Show
          Rick Hillegas added a comment - Attaching derby-6089-02-aa-addCheckToOldOverloads.diff. This patch makes the old overloads behave like the new overloads: If the jdbc type is not a legal Derby data type, then a SQLFeatureNotSupportedException is raised. I am running tests now. Touches the following files: -------------- M java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java The guts of the change to the embedded driver: check the data type whenever calling registerOutParameter. -------------- M java/engine/org/apache/derby/impl/jdbc/Util42.java M java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement42.java M java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement42.java M java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java M java/engine/org/apache/derby/impl/jdbc/Util.java M java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java M java/engine/org/apache/derby/impl/jdbc/EmbedResultSet42.java Some refactoring in order to support the embedded change. -------------- M java/client/org/apache/derby/client/am/CallableStatement.java The change to the client driver: check the data type whenever calling registerOutParameter. -------------- M java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java Add Dag's test case from 6089-repro-old-overloads.diff.
          Hide
          Rick Hillegas added a comment -

          Attaching derby-6089-02-ab-addCheckToOldOverloads.diff. The tests tripped one problem: the error has changed to a SQLFeatureNotSupportedException when you try to register an output parameter as a java.sql.Types.OTHER.

          Committed at subversion revision 1455602.

          Touches the following additional file:

          M java/testing/org/apache/derbyTesting/functionTests/master/outparams.out

          Show
          Rick Hillegas added a comment - Attaching derby-6089-02-ab-addCheckToOldOverloads.diff. The tests tripped one problem: the error has changed to a SQLFeatureNotSupportedException when you try to register an output parameter as a java.sql.Types.OTHER. Committed at subversion revision 1455602. Touches the following additional file: M java/testing/org/apache/derbyTesting/functionTests/master/outparams.out
          Hide
          Rick Hillegas added a comment -

          I believe that the work on this issue is done. Resolving.

          Show
          Rick Hillegas added a comment - I believe that the work on this issue is done. Resolving.
          Hide
          Myrna van Lunteren added a comment -

          Updated the j9_foundation canon to match the changes to master/outparams.out with revision http://svn.apache.org/viewvc?view=revision&revision=1456075.

          Show
          Myrna van Lunteren added a comment - Updated the j9_foundation canon to match the changes to master/outparams.out with revision http://svn.apache.org/viewvc?view=revision&revision=1456075 .
          Hide
          Dag H. Wanvik added a comment -

          Thanks, Rick. Patch is a good cleanup, closing this issue.

          Show
          Dag H. Wanvik added a comment - Thanks, Rick. Patch is a good cleanup, closing this issue.
          Hide
          Rick Hillegas added a comment -

          This cleanup cannot be backported to 10.8 because it touches JDBC 4.2 support classes which aren't present in 10.8.

          Show
          Rick Hillegas added a comment - This cleanup cannot be backported to 10.8 because it touches JDBC 4.2 support classes which aren't present in 10.8.

            People

            • Assignee:
              Rick Hillegas
              Reporter:
              Dag H. Wanvik
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development