## Summary
<!--Explain briefly what goes wrong and explain why you believe this is a bug and not the intended behavior of SQLite (if it is not a crash).-->**No review yet**

## Minimized query

```sql
PRAGMA case_sensitive_like = YES;
PRAGMA user_version;
PRAGMA wal_checkpoint('NOOP');
.timer 192319231923
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(w INT, x INT);
INSERT INTO t1(w,x) VALUES(1,10),(2,20),(3,30), (2,21),(3,31), (3,32);
CREATE INDEX t1wx ON t1(w,x);

DROP TABLE IF EXISTS t2;
CREATE TABLE t2(w INT, y VARCHAR(8));
INSERT INTO t2(w,y) VALUES(1,'one'),(2,'two'),(3,'three'),(4,'four');
CREATE INDEX t2wy ON t2(w,y);

SELECT cnt, xyz, (SELECT y FROM t2 WHERE w=cnt), '|' FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2) ORDER BY cnt, xyz;
SELECT cnt, xyz, lower((SELECT y FROM t2 WHERE w=cnt)), '|' FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2) ORDER BY cnt, xyz;
SELECT cnt, xyz, CASE WHEN (SELECT y FROM t2 WHERE w=cnt)=='two' THEN 'aaa' ELSE 'bbb' END, '|' FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2) ORDER BY +cnt;

WITH cte AS (SELECT * FROM t2 WHERE w IN (SELECT w FROM t2 LIMIT 5)) SELECT * FROM cte;
REINDEX;
INSERT INTO t1 DEFAULT VALUES;
WITH n AS NOT MATERIALIZED (SELECT * FROM t2) SELECT * FROM n WHERE y > 0;
INSERT INTO t1 SELECT * FROM t1;
```

## Actual output

```sql
0
0|-1|-1
Run Time: real 0.000 user 0.000024 sys 0.000000
Run Time: real 0.000 user 0.000116 sys 0.000000
Run Time: real 0.000 user 0.000029 sys 0.000000
Run Time: real 0.000 user 0.000081 sys 0.000000
Run Time: real 0.000 user 0.000004 sys 0.000000
Run Time: real 0.000 user 0.000053 sys 0.000000
Run Time: real 0.000 user 0.000016 sys 0.000000
Run Time: real 0.000 user 0.000054 sys 0.000000
1|1|one||
2|2|two||
3|3|three||
Run Time: real 0.000 user 0.000088 sys 0.000000
1|1|one||
2|2|two||
3|3|three||
Run Time: real 0.000 user 0.000057 sys 0.000000
1|1|bbb||
2|2|aaa||
3|3|bbb||
Run Time: real 0.000 user 0.000051 sys 0.000000
1|one
2|two
3|three
4|four
Run Time: real 0.001 user 0.000104 sys 0.000000
Run Time: real 0.000 user 0.000027 sys 0.000000
Run Time: real 0.000 user 0.000015 sys 0.000000
1|one
2|two
3|three
4|four
Run Time: real 0.000 user 0.000024 sys 0.000000
Run Time: real 0.000 user 0.000031 sys 0.000000
```

## Expectation

```sql
0
0|-1|-1
Run Time: real 0.000003 user 0.000010 sys 0.000000
Run Time: real 0.000041 user 0.000041 sys 0.000000
Run Time: real 0.000015 user 0.000015 sys 0.000000
Run Time: real 0.000034 user 0.000034 sys 0.000000
Run Time: real 0.000002 user 0.000002 sys 0.000000
Run Time: real 0.000019 user 0.000020 sys 0.000000
Run Time: real 0.000007 user 0.000006 sys 0.000000
Run Time: real 0.000020 user 0.000020 sys 0.000000
1|1|one||
2|2|two||
3|3|three||
Run Time: real 0.000043 user 0.000044 sys 0.000000
1|1|one||
2|2|two||
3|3|three||
Run Time: real 0.000025 user 0.000025 sys 0.000000
1|1|bbb||
2|2|aaa||
3|3|bbb||
Run Time: real 0.000021 user 0.000020 sys 0.000000
1|one
2|two
3|three
4|four
Run Time: real 0.000067 user 0.000067 sys 0.000000
Run Time: real 0.000011 user 0.000012 sys 0.000000
Run Time: real 0.000008 user 0.000008 sys 0.000000
1|one
2|two
3|three
4|four
Run Time: real 0.000010 user 0.000010 sys 0.000000
Run Time: real 0.000021 user 0.000022 sys 0.000000
```

## Flag

```

```

