SQLite Forum

Bug: inconsistent result when an optimization is on and off
Login
Hello developers,

For this case:

```
-- Version: latest(hash: check-in: 832ac4c1)
CREATE TABLE t0(c0 INT,c1 INT);
INSERT INTO t0 VALUES(10,10);

SELECT * FROM t0 JOIN (SELECT CAST(c0 AS TEXT) AS c2 FROM t0 UNION ALL SELECT c1 FROM t0) WHERE 10=c2; -- 2 lines
.testctrl optimizations 0x00000001;
SELECT '------';
SELECT * FROM t0 JOIN (SELECT CAST(c0 AS TEXT) AS c2 FROM t0 UNION ALL SELECT c1 FROM t0) WHERE 10=c2; -- 1 lines
```
When the optimization option `SQLITE_QueryFlattener` is off, we get incorrect result, which indicates that something could be going wrong here.

Hope it will be solved properly if there is indeed a problem here, and if there is no problem, your kind explanation would be appreciated.

Looking forward to your reply.

Thank you!