SQLite

View Ticket
Login
Ticket Hash: 65bdeb9739605cc22966f49208452996ff29a640
Title: "ORDER BY random()" gets optimized out
Status: Fixed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2014-02-26 02:26:29
Version Found In: 3.8.3.1
User Comments:
drh added on 2014-02-26 00:48:49: (text/x-fossil-wiki)
In the following query, the ORDER BY clause is ignored:

<blockquote><verbatim>
CREATE TABLE t1(a INTEGER PRIMARY KEY, b DEFAULT 1);
INSERT INTO t1(a) VALUES(1),(2),(3),(4),(5);
CREATE TABLE t2(x INTEGER PRIMARY KEY);
INSERT INTO t2 VALUES(1);
SELECT * FROM t1, t2 WHERE x=1 ORDER BY random();
</verbatim></blockquote>

This problem appears to have been introduced on 2013-06-21 (version 3.8.0)
with the introduction of the NGQP.