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

Distinct in subselect can return wrong results

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 10.1.3.1, 10.2.1.6
    • Component/s: SQL
    • Labels:
      None
    • Environment:
      All Platforms

      Description

      The second query should return two rows but returns just one.

      ij> select * from t1;
      I |V
      ----------------------
      1 |row 1
      2 |row 2

      2 rows selected
      ij> select * from t1, (select distinct 1 from t1) as sub(c);
      I |V |C
      ----------------------------------
      1 |row 1 |1

      1 row selected

      More specifically, this bug will show up when the sql layer does duplication elimination for distinct without a sorter (i.e. the underlying result set is already sorted). The result set will return correct data the first time, but after it is closed and re-opened it will not return any data rows.

        Attachments

        1. distinct.diff.txt
          3 kB
          Manish Khettry
        2. d466-10_1.patch
          3 kB
          A B

          Activity

            People

            • Assignee:
              mkhettry Manish Khettry
              Reporter:
              manish Manish Khettry
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: