/ Ticket Change Details
Login
Overview

Artifact ID: 4685201918074276438405d46331432d6c96bfd5
Ticket: d06a25c84454a372be4e4c970c3c4d4363197219
Incorrect result from a UNION with an ORDER BY
User & Date: drh 2016-02-08 22:22:47
Changes

  1. Change foundin to "3.10.2"
  2. Change icomment to:

    The following SQL code generates an incorrect answer of three rows instead of two:

    CREATE TABLE tx(id INTEGER PRIMARY KEY, a, b);
    INSERT INTO tx(a,b) VALUES(33,456);
    INSERT INTO tx(a,b) VALUES(33,789);
    
    SELECT DISTINCT t0.id, t0.a, t0.b
      FROM tx AS t0, tx AS t1
     WHERE t0.a=t1.a AND t1.a=33 AND t0.b=456
    UNION
    SELECT DISTINCT t0.id, t0.a, t0.b
      FROM tx AS t0, tx AS t1
     WHERE t0.a=t1.a AND t1.a=33 AND t0.b=789
     ORDER BY 1;
    

    Prior to and including check-in [93121d3097a43997] (version 3.8.3, 2013-12-17) the correct answer was obtained. After that, the test script above generates an assertion fault. At check-in [c0fa0c0e2de50d7e] (version 3.8.4, 2014-03-03) the assertion faults go away, but the incorrect answer is returned.

  3. Change login to "drh"
  4. Change mimetype to "text/x-fossil-wiki"
  5. Change severity to "Severe"
  6. Change status to "Open"
  7. Change title to "Incorrect result from a UNION with an ORDER BY"
  8. Change type to "Code_Defect"