SQLite

View Ticket
Login
2025-04-15
21:59
Correctly handle the case of a multi-column UNIQUE constraint that contains the ROWID as one of it columns, and then the columns of that UNIQUE are used in a row-value IN operator as a WHERE clause constraint. Reported by forum post b9647a113b. Problem introduced by [723f1be3d4a905a6], part of ticket [da78413751863]. (check-in: d22475b81c user: drh tags: trunk)
2017-11-17
21:01
Improved fix for ticket [da78413751863] that does not require disabling the query flattener as was done in [005d5b870625]. This also makes the code generator for vector IN operators a little easier to understand. (check-in: 723f1be3d4 user: drh tags: trunk)
2016-12-07
13:49
Always honor the sqlite3.dbOptFlags bitmask, regardless of compile-time options. Continuing fix for ticket [da78413751863]. (check-in: afab166313 user: drh tags: trunk)
2016-11-23
23:59 Fixed ticket [da78413751]: Query flattening causes bad byte-code for a vector IN operator plus 5 other changes (artifact: 10c8282517 user: drh)
21:01
Disable the query flattener optimization for SELECT statements that are on the RHS of vector IN operators. This is a hack that fixes the bug described in ticket [da7841375186386c]. A better solution that does not disable the query flattener is needed, but this will server for the time being. (check-in: 27438fb43d user: drh tags: branch-3.15)
2016-11-17
13:13
Disable the query flattener optimization for SELECT statements that are on the RHS of vector IN operators. This is a hack that fixes the bug described in ticket [da7841375186386c]. A better solution that does not disable the query flattener is needed, but this will server for the time being. (check-in: 005d5b8706 user: drh tags: trunk)
05:51 New ticket [da78413751] Query flattening causes bad byte-code for a vector IN operator. (artifact: ddc2e18789 user: drh)

Ticket Hash: da7841375186386c545ee39b8506ee4aaef43b60
Title: Query flattening causes bad byte-code for a vector IN operator
Status: Fixed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2016-11-23 23:59:54
8.63 years ago
Created: 2016-11-17 05:51:51
8.64 years ago
Version Found In: 3.15.1
User Comments:
drh added on 2016-11-17 05:51:51:

The following SQL results in a segfault due to an attempt to access a non-existent cursor:

REATE TABLE T1(a TEXT);
INSERT INTO T1(a) VALUES ('aaa');
CREATE TABLE T2(a TEXT PRIMARY KEY,n INT UNIQUE);
INSERT INTO T2(a, n) VALUES('aaa',0);
SELECT * FROM T2
WHERE (a,n) IN (SELECT T1.a, V.n FROM T1 JOIN (SELECT * FROM (SELECT 0 n)) V);

The problem might be caused by query flattening on the V table of the join on the RHS of the vector IN operator, but this is not a definitive diagnosis.