SQLite

View Ticket
Login
2025-05-29
18:44
Extend the fix for ticket [623eff57e76d45f6] so that it covers RIGHT JOIN in addition to LEFT JOIN. Problem reported by forum post 2025-05-29T15:10:14Z. (check-in: 29b1e1b976 user: drh tags: trunk)
2019-11-03
00:07 Fixed ticket [623eff57e7]: LEFT JOIN in view malfunctions with partial index on table plus 6 other changes (artifact: 4895f3bf95 user: drh)
00:07
The optimization of check-in [9b2879629c34fc0a] is incorrectly reasoned. The WHERE clause of the partial index might not be true if the table of the partial index is the right table of a left join. So disable the optimization in that case. Ticket [623eff57e76d45f6] (check-in: 3be19e1151 user: drh tags: trunk)
2019-11-02
21:41 New ticket [623eff57e7] LEFT JOIN in view malfunctions with partial index on table. (artifact: 4a2769593b user: mrigger)

Ticket Hash: 623eff57e76d45f64f7429ee8b28ea87fdfd2e18
Title: LEFT JOIN in view malfunctions with partial index on table
Status: Fixed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2019-11-03 00:07:56
5.58 years ago
Created: 2019-11-02 21:41:44
5.58 years ago
Version Found In: 3.30.0
User Comments:
mrigger added on 2019-11-02 21:41:44:

Consider the following test case:

CREATE TABLE t0(c0);
CREATE TABLE t1(c0);
INSERT INTO t1(c0) VALUES (0);
CREATE INDEX i0 ON t0(0) WHERE NULL IN (c0);
CREATE VIEW v0(c0) AS SELECT t0.c0 FROM t1 LEFT JOIN t0;
SELECT COUNT(*) FROM v0 WHERE NULL IN (v0.c0); -- expected: 0, actual: 1

I would expect that the COUNT(*) yields 0, since the WHERE condition yields NULL for the single row contained in the table:

SELECT NULL IN (v0.c0) FROM v0; -- NULL