SQLite Forum

Bug report: equivalence transfer results in incorrect output
Login
Hello,

Consider the following example:

```
CREATE TABLE t0(c0 INT, c1 INT UNIQUE);
CREATE TABLE t1(c0 INT);
INSERT INTO t0(c0, c1) VALUES (0, 1);
INSERT INTO t1(c0) VALUES (1);

SELECT ALL * FROM t1 NATURAL JOIN t0 WHERE (t1.c0=t0.c1);
SELECT ALL * FROM t1 NATURAL JOIN t0 WHERE (likely(t1.c0=t0.c1));
SELECT ALL * FROM t1,t0 WHERE (likely(t1.c0=t0.c1) AND t1.c0=t0.c0);
```
The resultset of the SELECT statements should be empty since there are no rows satisfing "t0.c0=t1.c0", but we got non-empty resultset from the second and the third statement.

It looks like a bug caused by some kind of equivalence transfer optimization described [here](https://sqlite.org/forum/forumpost/1c0afcbc0d).

I wonder whether it's an undiscovered bug.

Looking forward to your reply!

Thanks,

Wang Ke