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

Comparision with ALL (subquery) may give wrong result if constant is selected

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Duplicate
    • None
    • None
    • SQL
    • None
    • Repro attached
    • Wrong query result

    Description

      Consider the following:

      CREATE TABLE t1 (i INT PRIMARY KEY, j INT);
      CREATE TABLE t2 (i INT);
      INSERT INTO t1 VALUES (1,1),(2,2);
      INSERT INTO t2 VALUES (81);

      The two following queries should give the same result:

      SELECT * FROM t1 WHERE i < ALL (SELECT i FROM t2);
      SELECT * FROM t1 WHERE i < ALL (SELECT 81 FROM t2);

      But, they don't:

      ij> SELECT * FROM t1 WHERE i < ALL (SELECT i FROM t2);
      I |J
      -----------------------
      1 |1
      2 |2

      2 rows selected
      ij> SELECT * FROM t1 WHERE i < ALL (SELECT 81 FROM t2);
      I |J
      -----------------------

      0 rows selected
      ij>

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              bernt Bernt Johnsen
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: