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

SELECT with HAVING clause containing OR conditional incorrectly return 1 row - should return 2 rows - works correctly with 10.2 DB

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.3.1.4, 10.3.2.1, 10.4.1.3
    • Fix Version/s: 10.3.3.0, 10.4.1.3
    • Component/s: SQL
    • Labels:
      None
    • Bug behavior facts:
      Regression

      Description

      Attached program demonstrates the problem. Only one count is returned (matching CODE= GBR) - the count of CODE=CHA is not returned. Works fine with versions 10.1 and 10.2 or if program is run using 10.3 jars and 10.2 database (soft upgrade).

      Query:
      SELECT COUNT(t0.ID) FROM CTS1.TEST_TABLE t0
      GROUP BY t0.CODE
      HAVING (t0.CODE = 'GBR' OR t0.CODE = 'CHA') AND t0.CODE IS NOT NULL

      Incorrect results (see last line):
      Database product: Apache Derby
      Database version: 10.3.1.5 - (579866)
      Driver name: Apache Derby Embedded JDBC Driver
      Driver version: 10.3.1.5 - (579866)
      result: 2

      Correct results:
      Database product: Apache Derby
      Database version: 10.2.2.0 - (485682)
      Driver name: Apache Derby Embedded JDBC Driver
      Driver version: 10.2.2.0 - (485682)
      result: 4
      result: 2

        Attachments

        1. derby-3257_plan_10.2.txt
          3 kB
          Katherine Marsden
        2. derby-3257_plan_10.4.txt
          2 kB
          Katherine Marsden
        3. d3257_doNOTCommit.patch
          3 kB
          A B
        4. 42X24_error.sql
          0.4 kB
          Katherine Marsden
        5. TestHaving.java
          5 kB
          Katherine Marsden
        6. derby-3257_diff.txt
          8 kB
          Katherine Marsden
        7. derby-3257_stat.txt
          0.3 kB
          Katherine Marsden
        8. derby-3257_diff2.txt
          8 kB
          Katherine Marsden

          Issue Links

            Activity

              People

              • Assignee:
                kmarsden Katherine Marsden
                Reporter:
                stan Sun Seng David Tan
              • Votes:
                1 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: