SQLite

View Ticket
Login
Ticket Hash: 9cf6c9bb51e53bded445bedb200de5cb516ce867
Title: "<" or "<=" comparison of rowid and non-numeric text value sometimes gets the wrong answer.
Status: Closed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2019-05-08 14:03:50
Version Found In:
User Comments:
dan added on 2019-05-08 11:37:44: (text/x-fossil-wiki)
In the following, the second SELECT statement returns 0 rows:

<verbatim>
  CREATE TABLE t14(x INTEGER PRIMARY KEY);
  INSERT INTO t14(x) VALUES (100);
  SELECT * FROM t14 WHERE x < 'a' ORDER BY rowid ASC;
  SELECT * FROM t14 WHERE x < 'a' ORDER BY rowid DESC;
</verbatim>

dan added on 2019-05-08 11:40:33: (text/x-fossil-wiki)
This has been a problem since before version 3.8.0.

dan added on 2019-05-08 11:54:06: (text/x-fossil-wiki)
Fixed by [658b84d7].

drh added on 2019-05-08 14:03:50: (text/x-fossil-wiki)
This problem was originally reported on the SQLite mailing list
by Manuel Rigger.

The original problem report used PRAGMA
reverse_unordered_selects.  However, as the script above shows,
the problem has nothing to do with reverse_unordered_selects.
The problem was a defect in the implementation of some of the
(rarely used) comparison opcodes in the bytecode engine.