SQLite

View Ticket
Login
Ticket Hash: 5c6955204c392ae763a95a56e7d83b103a934869
Title: Incorrect result on a table scan of a partial index
Status: Fixed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Code_Generator Resolution: Fixed
Last Modified: 2019-05-04 17:34:15
Version Found In:
User Comments:
drh added on 2019-05-04 16:59:49:

The final SELECT statement in the following SQL returns no rows, but it should return a single row with a NULL value:

CREATE TABLE t0(c0);
CREATE INDEX index_0 ON t0(c0) WHERE c0 NOT NULL;
INSERT INTO t0(c0) VALUES (NULL);
SELECT * FROM t0 WHERE c0 OR 1;

Bisecting this error lands on check-in [fe1874321ba31cec]. But I suspect that is just where the symptoms first appeared and that the problem is a deeper and older error in the theorem prover that (incorrectly) establishes that c0 is not null when "c0 OR 1" is true.

This issue was discovered by Manuel Rigger and reported on the SQLite mailing list.


drh added on 2019-05-04 17:34:15:

Confirmed: the error was in the theorem prover. The error goes all the way back to when partial index support was first added to SQLite in version 3.8.0 (2013-08-26). The problem is fixed by check-in [c2e439bccc40825e211bf] (2019-05-04).