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

Need stricter checking of ORDER BY clause in VALUES expressions

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments


    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s:,,,,,,,,,,,,,,,
    • Fix Version/s:
    • Component/s: SQL
    • Issue & fix info:
      Repro attached


      We only support column numbers in ORDER BY clauses in VALUES expression, as seen by this error message:

      ij> values 1,2 order by 1+2;
      ERROR 42878: The ORDER BY clause of a SELECT UNION statement only supports unqualified column references and column position numbers. Other expressions are not currently supported. (errorCode = 30000)

      However, the checks let some unsupported expressions through and produce strange results. For example:

      ij> values 1 order by 1+2;
      1 |2
      1 |3

      1 row selected

      It should probably have raised the same exception as the first query. And if not, the result should only have had one column.

      And the next example should probably have raised a syntax error too, instead of a NullPointerException:

      ij> values 1 order by int(1);
      ERROR XJ001: Java exception: ': java.lang.NullPointerException'. (errorCode = 0)


        1. derby-6009.diff
          9 kB
          Dag H. Wanvik
        2. derby-6009.stat
          0.5 kB
          Dag H. Wanvik
        3. derby-6009b.diff
          9 kB
          Dag H. Wanvik
        4. derby-6009b.stat
          0.5 kB
          Dag H. Wanvik
        5. derby-6009c.diff
          9 kB
          Dag H. Wanvik
        6. derby-6009c.stat
          0.5 kB
          Dag H. Wanvik

        Issue Links



            • Assignee:
              dagw Dag H. Wanvik
              knutanders Knut Anders Hatlen


              • Created:

                Issue deployment