SQLite

View Ticket
Login
Ticket Hash: 4766f444868a45c6fe1f8b785860140df94d94b6
Title: ORDER BY handling with indexes on expressions
Status: Closed Type: Code_Defect
Severity: Critical Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2016-10-10 14:38:24
Version Found In: trunk
User Comments:
dan added on 2016-10-10 14:20:06:

When there is an index on an expression that matches the first term of an ORDER BY expression-list, SQLite is ignoring all subsequent expressions. For example:

  sqlite> CREATE TABLE t1(x, y);
  sqlite> INSERT INTO t1 VALUES(1, 1);
  sqlite> INSERT INTO t1 VALUES(1, 2);
  sqlite> INSERT INTO t1 VALUES(2, 2);
  sqlite> INSERT INTO t1 VALUES(2, 1);
  sqlite> SELECT * FROM t1 ORDER BY x+0,y;
  1|1
  1|2
  2|1
  2|2
  sqlite> CREATE INDEX i1 ON t1(x+0);
  sqlite> SELECT * FROM t1 ORDER BY x+0, y;
  1|1
  1|2
  2|2
  2|1


dan added on 2016-10-10 14:38:24:

Fixed by [aebe429e].