SQLite

View Ticket
Login
Ticket Hash: 82ac75ba0093e5dcd606150b85dff5f8bdcd3dec
Title: Incorrect result for query with 0 >= t0.c0 AND t0.c0 = v0.c0 condition
Status: Fixed Type: Code_Defect
Severity: Important Priority: Low
Subsystem: Unknown Resolution: Fixed
Last Modified: 2020-01-08 01:44:07
Version Found In: 3.30.0
User Comments:
mrigger added on 2020-01-07 21:41:37:

Consider the following test case:

CREATE TABLE t0(c0);
INSERT INTO t0 VALUES('0');
CREATE VIEW v0(c0) AS SELECT CAST(0 AS INT) FROM t0;
SELECT * FROM t0, v0 WHERE 0 >= t0.c0 AND t0.c0 = v0.c0; -- unexpected: fetches row

Unexpectedly, the query fetches a row. When removing the AND and its right expression, no row is fetched:

SELECT * FROM t0, v0 WHERE 0 >= t0.c0; -- fetches no row

Also the following expression evaluates to FALSE:

SELECT 0 >= t0.c0 AND t0.c0 = v0.c0 FROM t0, v0; -- 0