SQLite

View Ticket
Login
2010-08-13
16:50 Closed ticket [e4b8a2ba6e]: Problem with DISTINCT in sub-queries in a FROM clause. plus 3 other changes (artifact: 20f7d054d2 user: dan)
16:38
Do not apply the flattening optimization if the sub-query is DISTINCT. Fix for [e4b8a2ba6e]. (check-in: 497aafd8ed user: dan tags: trunk)
16:19 New ticket [e4b8a2ba6e] Problem with DISTINCT in sub-queries in a FROM clause.. (artifact: f77237eecc user: dan)

Ticket Hash: e4b8a2ba6e06d34086362c0caeff05e523184a43
Title: Problem with DISTINCT in sub-queries in a FROM clause.
Status: Closed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Code_Generator Resolution: Fixed
Last Modified: 2010-08-13 16:50:01
14.89 years ago
Created: 2010-08-13 16:19:39
14.89 years ago
Version Found In: 3.7.1
Description:
Internally, SQLite is transforming queries of the form:
SELECT f(x,y) FROM (SELECT DISTINCT x, y FROM tbl);

to

SELECT DISTINCT f(x,y) FROM tbl;

But this is only valid if f(x,y) is distinct for all distinct (x,y) rows. And if f(x,y) is really just a function of (x,y). It may not be if it includes some user-defined SQL functions, such as randomblob().


dan added on 2010-08-13 16:50:01:

This problem has been present since at least version 3.5.1.