SQLite

Ticket Change Details
Login
Overview

Artifact ID: 51389ac452f6999ef9b033d0d4a0a7ef15c51c15
Ticket: 0c4df46116e90f927a54103c4ed82a825a18763f
Incorrect result with ORDER BY DESC and LIMIT
User & Date: drh 2016-09-07 00:42:45
Changes

  1. foundin changed to: "3.14.1"
  2. icomment:
    In the following SQL, the first query gives the correct 3 lines of result
    in the correct order.  But the second query returns the second line of result,
    not the first line as it should:
    
    <blockquote><pre>
    CREATE TABLE t1(a,b,c);
    CREATE INDEX t1x ON t1(a,b,c);
    INSERT INTO t1 VALUES(0,1,99),(0,1,0),(0,0,0);
    SELECT * FROM t1 WHERE a=0 AND (c=0 OR c=99) ORDER BY c DESC;
    SELECT * FROM t1 WHERE a=0 AND (c=0 OR c=99) ORDER BY c DESC LIMIT 1;
    </pre></blockquote>
    
    This problem seems to have been introduced by check-in [559733b09e96]
    on 2016-05-20 and was released with version 3.14.0.
    
  3. login: "drh"
  4. mimetype: "text/x-fossil-wiki"
  5. severity changed to: "Severe"
  6. status changed to: "Open"
  7. title changed to: "Incorrect result with ORDER BY DESC and LIMIT"
  8. type changed to: "Code_Defect"