SQLite

View Ticket
Login
2017-07-17
19:25
When checking for the WHERE-clause push-down optimization, verify that all terms of the compound inner SELECT are non-aggregate, not just the last term. Fix for ticket [f7f8c97e97597]. (Closed-Leaf check-in: adc082c1 user: drh tags: push-down-backport)
2016-04-25
02:20
When checking for the WHERE-clause push-down optimization, verify that all terms of the compound inner SELECT are non-aggregate, not just the last term. Fix for ticket [f7f8c97e97597]. (check-in: ec215f94 user: drh tags: trunk)
02:20 Fixed ticket [f7f8c97e]: Valid query fails to compile due to WHERE clause optimization plus 5 other changes (artifact: c320a9dd user: drh)
01:43 New ticket [f7f8c97e]. (artifact: 1db949b0 user: drh)

Ticket Hash: f7f8c97e975978d45cc2b1ea722af90e0607adc6
Title: Valid query fails to compile due to WHERE clause optimization
Status: Fixed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2016-04-25 02:20:09
Version Found In: 3.12.2
User Comments:
drh added on 2016-04-25 01:43:33:

The following query works and gives the correct answer for SQLite version 3.8.10 but fails to compile with a "misuse of aggregate" error for 3.8.11.

CREATE TABLE t1(a int, b int);
INSERT INTO t1 VALUES(1,2),(1,18),(2,19);
SELECT x, y FROM (
  SELECT a AS x, sum(b) AS y FROM t1 GROUP BY a
  UNION
  SELECT 98, 99
) AS w WHERE y>=20;

The problem seems to have been introduced by check-in [6df18e949d36] on 2015-06-02. The problem was reported on the sqlite-users mailing list by Jean-Luc Hainaut.