Derby
  1. Derby
  2. DERBY-3512

Using functions, you can create a LONG VARCHAR value which is longer than the maximum length of a Derby LONG VARCHAR

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 10.4.1.3
    • Fix Version/s: None
    • Component/s: SQL
    • Urgency:
      Normal
    • Issue & fix info:
      High Value Fix, Repro attached

      Description

      I can create a static method which returns a long String and register this as a function which returns LONG VARCHAR. I am able to invoke this function and create a LONG VARCHAR value which is longer than the maximum length which Derby allows for this datatype (32700 characters).

      It is not clear to me what is supposed to happen in this situation according to the SQL standard. However, the current behavior seems wrong. Here are two possible correct behaviors:

      1) Raise an exception if the user-coded method violates the declared contract of the CREATE FUNCTION statement.

      2) Silently truncate the value returned by the user-coded method.

      There may be a similar problem with methods which return byte[] and which are registered as functions returning (LONG) VARCHAR FOR BIT DATA. However, experiments to test this are blocked by DERBY-3511.

      I will attach a test case demonstrating the problem.

      1. BigStringMaker.java
        0.6 kB
        Rick Hillegas
      2. bigStrings.sql
        0.3 kB
        Rick Hillegas

        Issue Links

          Activity

          Hide
          Tiago R. Espinha added a comment -

          Triaged for 10.5.2.

          Checked High Value Fix and Repro attached.
          Assigned Normal urgency.

          Show
          Tiago R. Espinha added a comment - Triaged for 10.5.2. Checked High Value Fix and Repro attached. Assigned Normal urgency.
          Hide
          Rick Hillegas added a comment -

          Right, DERBY-3341 implements silent truncation.

          Show
          Rick Hillegas added a comment - Right, DERBY-3341 implements silent truncation.
          Hide
          Daniel John Debrunner added a comment -

          It should match the behaviour for VARCHAR, which today is option 2), which I think matches DERBY-3341, silent truncation right?

          Show
          Daniel John Debrunner added a comment - It should match the behaviour for VARCHAR, which today is option 2), which I think matches DERBY-3341 , silent truncation right?
          Hide
          Rick Hillegas added a comment -

          It is possible that a similar issue affects methods which return byte[] and are registered as (LONG) VARCHAR FOR BIT DATA. When DERBY-3511 is fixed, we can investigate the behavior of the long binary types.

          Show
          Rick Hillegas added a comment - It is possible that a similar issue affects methods which return byte[] and are registered as (LONG) VARCHAR FOR BIT DATA. When DERBY-3511 is fixed, we can investigate the behavior of the long binary types.
          Hide
          Rick Hillegas added a comment -

          It is unclear what the correct behavior here should be. However, it is likely that we want this to be the same behavior that we will enforce for the ResultSets returned by Derby-style table functions. See DERBY-3341.

          Show
          Rick Hillegas added a comment - It is unclear what the correct behavior here should be. However, it is likely that we want this to be the same behavior that we will enforce for the ResultSets returned by Derby-style table functions. See DERBY-3341 .
          Hide
          Rick Hillegas added a comment -

          To demonstrate the problem, do the following:

          1) Compile BigStringMaker

          2) Run bigStrings.sql through ij.

          Show
          Rick Hillegas added a comment - To demonstrate the problem, do the following: 1) Compile BigStringMaker 2) Run bigStrings.sql through ij.

            People

            • Assignee:
              Unassigned
              Reporter:
              Rick Hillegas
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Development