SQLite

View Ticket
Login
2017-10-27
23:28
I was a little concerned about this check-in. Though I could not generate a failure myself, I thought it was risky. I checked it in for further testing. Then, overnight, OSSFuzz found a failure case for me. So the change is now moved out into a deadend branch. Was: Use OP_SCopy rather than OP_Copy to transfer results from a co-routine to its consumer. This undoes an earlier fix for ticket [98825a79ce] by check-in [ec6a06246e] because that problem no longer occurs due to WHERE clause push-down. (Closed-Leaf check-in: 0926df09 user: drh tags: mistake)
2014-04-03
16:57 Fixed ticket [98825a79]: Incorrect result from a DISTINCT + GROUP BY + ORDER BY query plus 5 other changes (artifact: 2c4eead4 user: drh)
16:29
Use OP_Copy instead of OP_SCopy when moving results out of a subquery, to prevent the subquery results from changing out from under the outer query. Fix for ticket [98825a79ce1456]. Problem introduced by check-in [1e64dd782a126f48d78]. (check-in: d5513dfa user: drh tags: trunk)
16:16
Use OP_Copy instead of OP_SCopy when moving results out of a subquery, to prevent the subquery results from changing out from under the outer query. Fix for ticket [98825a79ce1456]. Problem introduced by check-in [1e64dd782a126f48d78]. (check-in: ec6a0624 user: drh tags: branch-3.8.4)
15:17 New ticket [98825a79] Incorrect result from a DISTINCT + GROUP BY + ORDER BY query. (artifact: b556e7c9 user: drh)

Ticket Hash: 98825a79ce145686392d8074032ae54863aa21a3
Title: Incorrect result from a DISTINCT + GROUP BY + ORDER BY query
Status: Fixed Type: Code_Defect
Severity: Critical Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2014-04-03 16:57:11
Version Found In: 3.8.4.2
User Comments:
drh added on 2014-04-03 15:17:34:

The following query answers 'wrong' even though the correct answer is 'right':

CREATE TABLE t1(x);
INSERT INTO t1 VALUES('right'),('wrong');
SELECT DISTINCT x
 FROM (SELECT x FROM t1 GROUP BY x)
 WHERE x='right'
 ORDER BY x;

Bisecting shows that this problem was introduced by check-in [1e64dd782a126f48d78c4] on 2014-02-08 and first appeared in SQLite version 3.8.4.