SQLite

View Ticket
Login
Ticket Hash: 57af00b6642ecd684830edd964ea957fdf6a121d
Title: Expression computed on row yields incorrect result
Status: Fixed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2019-09-02 00:58:56
Version Found In: 3.29.0
User Comments:
mrigger added on 2019-09-01 16:02:46: (text/x-fossil-wiki)
Consider the test case below:

<pre>
CREATE TABLE t0(c0 REAL, c1 TEXT);
CREATE INDEX i0 ON t0(+c0, c0);
INSERT INTO t0(c0) VALUES(0);
SELECT CAST(+ t0.c0 AS BLOB) LIKE 0 FROM t0; -- expected: 0, actual: 1
</pre>

When not creating the index, the expression evaluates to FALSE, as expected. When the expression is used in the WHERE condition, the result is also as expected (i.e., the row is not fetched):

<pre>
SELECT * FROM t0 WHERE CAST(+ t0.c0 AS BLOB) LIKE 0; -- no row is fetched
</pre>

This bug is somewhat different from all the other bugs that I found, since typically, an expression used in the WHERE clause can lead to an incorrect result.

drh added on 2019-09-01 19:46:37: (text/x-fossil-wiki)
Problem apparently introduced by check-in [a47efb7c8520a011]