Derby
  1. Derby
  2. DERBY-4371

Non-selected columns for SELECT DISTINCT allowed in ORDER BY clause if ordered by expression

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 10.5.1.1
    • Fix Version/s: 10.7.1.1
    • Component/s: SQL
    • Labels:
      None
    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Wrong query result

      Description

      How to repeat:

      ij> create table t (i integer, j integer);;
      0 rows inserted/updated/deleted
      ij> insert into t values (1,2),(1,3);
      2 rows inserted/updated/deleted
      ij> select distinct i from t order by j;
      ERROR 42879: The ORDER BY clause may not contain column 'J', since the query specifies DISTINCT and that column does not appear in the query result.
      ij> select distinct i from t order by j*2;
      I
      -----------
      1
      1

      2 rows selected

      1. derby-4371-7.diff
        5 kB
        Nirmal Fernando
      2. derby-4371-tests.diff
        8 kB
        Nirmal Fernando
      3. derby-4371-6.diff
        5 kB
        Nirmal Fernando
      4. derby-4371-5.diff
        5 kB
        Nirmal Fernando
      5. DERBY-4371-4.diff
        4 kB
        Nirmal Fernando
      6. DERBY-4371-3.diff
        4 kB
        Nirmal Fernando
      7. DERBY-4371-2.diff
        2 kB
        Nirmal Fernando
      8. DERBY-4371.diff
        2 kB
        Nirmal Fernando

        Issue Links

          Activity

          Bernt M. Johnsen created issue -
          Bernt M. Johnsen made changes -
          Field Original Value New Value
          Priority Major [ 3 ] Critical [ 2 ]
          Bernt M. Johnsen made changes -
          Issue & fix info [Repro attached]
          Knut Anders Hatlen made changes -
          Link This issue relates to DERBY-4406 [ DERBY-4406 ]
          Nirmal Fernando made changes -
          Assignee C.S. Nirmal J. Fernando [ nirmal ]
          Nirmal Fernando made changes -
          Attachment DERBY-4371.diff [ 12442750 ]
          Nirmal Fernando made changes -
          Attachment DERBY-4371-2.diff [ 12442872 ]
          Nirmal Fernando made changes -
          Attachment DERBY-4371-3.diff [ 12443151 ]
          Nirmal Fernando made changes -
          Attachment DERBY-4371-4.diff [ 12443459 ]
          Nirmal Fernando made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Nirmal Fernando made changes -
          Attachment derby-4371-5.diff [ 12452537 ]
          Nirmal Fernando made changes -
          Attachment derby-4371-5.diff [ 12452545 ]
          Nirmal Fernando made changes -
          Attachment derby-4371-5.diff [ 12452537 ]
          Nirmal Fernando made changes -
          Issue & fix info [Repro attached] [Patch Available, Repro attached]
          Nirmal Fernando made changes -
          Attachment derby-4371-5.diff [ 12452545 ]
          Nirmal Fernando made changes -
          Attachment derby-4371-5.diff [ 12452549 ]
          Nirmal Fernando made changes -
          Attachment derby-4371-6.diff [ 12452628 ]
          Nirmal Fernando made changes -
          Attachment derby-4371-tests.diff [ 12452649 ]
          Nirmal Fernando made changes -
          Attachment derby-4371-7.diff [ 12452902 ]
          Knut Anders Hatlen made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Issue & fix info [Repro attached, Patch Available] [Repro attached]
          Fix Version/s 10.7.0.0 [ 12314971 ]
          Resolution Fixed [ 1 ]
          Rick Hillegas made changes -
          Fix Version/s 10.7.1.1 [ 12315564 ]
          Fix Version/s 10.7.1.0 [ 12314971 ]
          Knut Anders Hatlen made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Gavin made changes -
          Workflow jira [ 12475129 ] Default workflow, editable Closed status [ 12802730 ]

            People

            • Assignee:
              Nirmal Fernando
              Reporter:
              Bernt M. Johnsen
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development