SQLite

View Ticket
Login
Ticket Hash: c997b11c4d53a2ee9983111d0c676dd7d4f01ec7
Title: ORDER BY clause ignored in 3-way join query
Status: Fixed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Code_Generator Resolution: Fixed
Last Modified: 2013-01-09 14:43:29
Version Found In:
Description:
$ ./sqlite3 
SQLite version 3.7.16 2013-01-08 12:48:10
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE t1(a INTEGER PRIMARY KEY);
sqlite> CREATE TABLE t2(b INTEGER PRIMARY KEY, c INTEGER);
sqlite> CREATE TABLE t3(d INTEGER);
sqlite> 
sqlite> INSERT INTO t1 VALUES(1);
sqlite> INSERT INTO t1 VALUES(2);
sqlite> INSERT INTO t1 VALUES(3);
sqlite> 
sqlite> INSERT INTO t2 VALUES(3, 1);
sqlite> INSERT INTO t2 VALUES(4, 2);
sqlite> INSERT INTO t2 VALUES(5, 3);
sqlite> 
sqlite> INSERT INTO t3 VALUES(4);
sqlite> INSERT INTO t3 VALUES(3);
sqlite> INSERT INTO t3 VALUES(5);
sqlite>
sqlite> SELECT t1.a FROM t1, t2, t3 WHERE t1.a=t2.c AND t2.b=t3.d ORDER BY t1.a;
2
1
3

Problem introduced by [956e4d7f89].

First reported on the mailing list: http://www.mail-archive.com/sqlite-users@sqlite.org/msg74717.html