|14:45||Only disable the one-pass DELETE optimization if the WHERE clause contains a correlated subquery. Uncorrelated subqueries are allowed. This is a refinement of check-in [3f221f592a9a1] that is the fix for ticket [dc6ebeda9396087]. (check-in: aae38969 user: drh tags: trunk)|
|13:46||• Fixed ticket [dc6ebeda]: Incorrect DELETE due to the one-pass optimization plus 6 other changes (artifact: d9f4aeb0 user: drh)|
|12:18||Disable the multi-row one-pass DELETE optimization when the WHERE clause contains a subquery. Fix for ticket [dc6ebeda9396087]. (check-in: 3f221f59 user: drh tags: trunk)|
|12:00||• New ticket [dc6ebeda] Incorrect DELETE due to the one-pass optimization. (artifact: 16a4e843 user: drh)|
|Title:||Incorrect DELETE due to the one-pass optimization|
|Last Modified:||2016-05-02 13:46:58|
|Version Found In:||3.12.2|
drh added on 2016-05-02 12:00:40:
The DELETE statement on the third line of the example below only deletes a single row, rather than two rows as expected. The correct behavior, confirmed by running on PostgreSQL, is to delete two rows, such that the final answer is a single row with value "1".
CREATE TABLE t1(x INT); INSERT INTO t1 VALUES(1),(2),(3); DELETE FROM t1 WHERE EXISTS(SELECT 1 FROM t1 AS v WHERE v.x=t1.x-1); SELECT * FROM t1;
Bisecting shows that this problem results from the one-pass optimization at check-in [8b93cc59370]. The problem was reported on the sqlite-users mailing list by Rob Golsteijn.
drh added on 2016-05-02 13:46:58:
Versions affected by this bug: 3.9.0 through 3.12.2.