## 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
ATTACH DATABASE ':memory:' AS aux43;
.recover
PRAGMA trusted_schema = TRUE;
DROP TABLE IF EXISTS t1;
CREATE VIRTUAL TABLE t0 USING fts4("x", "y", "z");
DROP TABLE t0;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('a','b',jsonb_extract(5.0, '$')), ('a','c',5.0), ('b','d',-8.25);
SELECT a,b,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
CREATE TABLE t1(w INT, x INT);
INSERT INTO t1(w,x) VALUES(sqlite_compileoption_used('ENABLE_FTS3'),unixepoch(1.7976931348623157e+308)),(2,20),(3,30), (2,21),(3,31), (3,32);
CREATE INDEX t1wx ON t1(w,x);
DROP TABLE IF EXISTS main.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;
DELETE FROM t2 WHERE 0 RETURNING *;
ANALYZE;
CREATE  INDEX IF NOT EXISTS idx_t1_718 ON t1((w + 1));
WITH cte(x) AS (VALUES(1),(2),(3)) SELECT * FROM cte;
DROP TRIGGER IF EXISTS t2;
INSERT OR ABORT INTO t1 VALUES ('x', '');
DELETE FROM t2 WHERE y IS NULL;
SELECT * FROM t2 WHERE w IN (SELECT w FROM t2 WHERE w IS NULL);
INSERT OR ABORT INTO t2 VALUES (-1, 'x');
SELECT COUNT(*) FROM t1;
SELECT MIN(y) FROM t2;
DETACH DATABASE aux43;
```

## Actual output

```sql
PRAGMA foreign_keys=OFF;
BEGIN;
PRAGMA writable_schema = on;
PRAGMA writable_schema = off;
COMMIT;
1|1|one||
2|2|two||
3|3|three||
1|1|one||
2|2|two||
3|3|three||
1|1|bbb||
2|2|aaa||
3|3|bbb||
1
2
3
7
four
```

## Expectation

```sql

```

## Flag

```

```

