## 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
BEGIN DEFERRED TRANSACTION;
.timeout concat(999999, NULL, 999999)
.once log.txt
SAVEPOINT sp895;
PRAGMA reverse_unordered_selects;
PRAGMA reverse_unordered_selects = YES;
PRAGMA cache_spill;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (1, 'Wernher', 10, 100);
INSERT INTO t1 VALUES (2, 'von', 20, 200);
INSERT INTO t1 VALUES (3, 'Braun', 30, 300);
CREATE INDEX t1bc ON t1(b, c);
PRAGMA writable_schema = ON;
.imposter t1bc t2

SELECT  * FROM t2;
SELECT b, c FROM t1 ORDER BY b, c;
.quit
.changes on
PRAGMA page_size='false';
CREATE TABLE /* PRAGMA max_page_count = 5000000; */ t1(a INT PRIMARY KEY, b BLOB, c INT) WITHOUT ROWID;
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE NOT NOT (NOT x<100) INSERT INTO t1(a,b,c) SELECT x*2, zeroblob(100), x FROM c) ;
UPDATE t1 SET b=zeroblob(1000) WHERE a=198;
CREATE TABLE t2(x INTEGER PRIMARY KEY, y INT);
CREATE TABLE T (
  A VARCHAR(20),
  B VARCHAR(10),
  C INTEGER,
  PRIMARY KEY (A, B)
);
INSERT INTO T VALUES ('a', 'p', -2147483648);
INSERT INTO T VALUES ('b', 'q', 100);
INSERT INTO T VALUES ('b', 'r', 200);
INSERT INTO T VALUES ('c', 's', 300);
INSERT INTO T VALUES ('d', 't', 2147483647);
INSERT INTO T VALUES ('b', 't', 50);
SELECT A, COUNT(*) AS D, SUM(C) AS E FROM T GROUP BY A HAVING COUNT(*) > 1;
INSERT INTO t2(y) VALUES(198),(187),(100);
SELECT y, c FROM t2 LEFT JOIN t1 ON y=a ORDER BY x;
SELECT y, c FROM t1 RIGHT JOIN t2 ON y=a ORDER BY x;
SELECT * FROM t1 NATURAL JOIN t1;
DROP INDEX IF EXISTS t2;
SELECT COUNT(*) FROM t2;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t2_5905 ON t2((y + 1));
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t2_7184 ON t2((x + 1)) WHERE x > 0;
VACUUM;
CREATE TABLE T (
  a TEXT,
  b REAL
);
INSERT INTO T VALUES ('a',100.0), ('b',-200.5), ('c',9e999);
SELECT a,b,
LEAD(b,1) OVER (ORDER BY b DESC) AS c,
NTILE(2) OVER (ORDER BY b DESC) AS d FROM T;
ANALYZE T;
RELEASE sp895;
ALTER TABLE T RENAME TO T_r129;
SELECT STRING_AGG(B) FROM T;
WITH cte AS (SELECT B, COUNT(*) AS cnt FROM T GROUP BY B) SELECT * FROM cte;
INSERT INTO t2 SELECT * FROM t2;
SELECT * FROM T NATURAL JOIN t2;

SELECT COUNT(*) FROM t1;
ALTER TABLE t2 RENAME TO t2_r2071;
.once log.txt
SAVEPOINT sp895;
PRAGMA reverse_unordered_selects;
PRAGMA reverse_unordered_selects = YES;
PRAGMA cache_spill;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (1, 'Wernher', 10, 100);
INSERT INTO t1 VALUES (2, 'von', 20, 200);
INSERT INTO t1 VALUES (3, 'Braun', 30, 300);
CREATE INDEX t1bc ON t1(b, c);
PRAGMA writable_schema = ON;
.imposter t1bc t2

SELECT  * FROM t2;
SELECT b, c FROM t1 ORDER BY b, c;
.quit
.changes on
PRAGMA page_size='false';
CREATE TABLE /* PRAGMA max_page_count = 5000000; */ t1(a INT PRIMARY KEY, b BLOB, c INT) WITHOUT ROWID;
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE NOT NOT (NOT x<100) INSERT INTO t1(a,b,c) SELECT x*2, zeroblob(100), x FROM c) ;
UPDATE t1 SET b=zeroblob(1000) WHERE a=198;
CREATE TABLE t2(x INTEGER PRIMARY KEY, y INT);
CREATE TABLE T (
  A VARCHAR(20),
  B VARCHAR(10),
  C INTEGER,
  PRIMARY KEY (A, B)
);
INSERT INTO T VALUES ('a', 'p', -2147483648);
INSERT INTO T VALUES ('b', 'q', 100);
INSERT INTO T VALUES ('b', 'r', 200);
INSERT INTO T VALUES ('c', 's', 300);
INSERT INTO T VALUES ('d', 't', 2147483647);
INSERT INTO T VALUES ('b', 't', 50);
SELECT A, COUNT(*) AS D, SUM(C) AS E FROM T GROUP BY A HAVING COUNT(*) > 1;
INSERT INTO t2(y) VALUES(198),(187),(100);
SELECT y, c FROM t2 LEFT JOIN t1 ON y=a ORDER BY x;
SELECT y, c FROM t1 RIGHT JOIN t2 ON y=a ORDER BY x;
SELECT * FROM t1 NATURAL JOIN t1;
DROP INDEX IF EXISTS t2;
SELECT COUNT(*) FROM t2;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t2_5905 ON t2((y + 1));
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t2_7184 ON t2((x + 1)) WHERE x > 0;
VACUUM;
CREATE TABLE T (
  a TEXT,
  b REAL
);
INSERT INTO T VALUES ('a',100.0), ('b',-200.5), ('c',9e999);
SELECT a,b,
LEAD(b,1) OVER (ORDER BY b DESC) AS c,
NTILE(2) OVER (ORDER BY b DESC) AS d FROM T;
ANALYZE T;
RELEASE sp895;
ALTER TABLE T RENAME TO T_r129;
SELECT STRING_AGG(B) FROM T;
WITH cte AS (SELECT B, COUNT(*) AS cnt FROM T GROUP BY B) SELECT * FROM cte;
INSERT INTO t2 SELECT * FROM t2;
SELECT * FROM T NATURAL JOIN t2;

SELECT COUNT(*) FROM t1;
ALTER TABLE t2 RENAME TO t2_r2071;
.once log.txt
SAVEPOINT sp895;
PRAGMA reverse_unordered_selects;
PRAGMA reverse_unordered_selects = YES;
PRAGMA cache_spill;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT, d INT);
INSERT INTO t1 VALUES (1, 'Wernher', 10, 100);
INSERT INTO t1 VALUES (2, 'von', 20, 200);
INSERT INTO t1 VALUES (3, 'Braun', 30, 300);
CREATE INDEX t1bc ON t1(b, c);
PRAGMA writable_schema = ON;
.imposter t1bc t2

SELECT  * FROM t2;
SELECT b, c FROM t1 ORDER BY b, c;
.quit
.changes on
PRAGMA page_size='false';
CREATE TABLE /* PRAGMA max_page_count = 5000000; */ t1(a INT PRIMARY KEY, b BLOB, c INT) WITHOUT ROWID;
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE NOT NOT (NOT x<100) INSERT INTO t1(a,b,c) SELECT x*2, zeroblob(100), x FROM c) ;
UPDATE t1 SET b=zeroblob(1000) WHERE a=198;
CREATE TABLE t2(x INTEGER PRIMARY KEY, y INT);
CREATE TABLE T (
  A VARCHAR(20),
  B VARCHAR(10),
  C INTEGER,
  PRIMARY KEY (A, B)
);
INSERT INTO T VALUES ('a', 'p', -2147483648);
INSERT INTO T VALUES ('b', 'q', 100);
INSERT INTO T VALUES ('b', 'r', 200);
INSERT INTO T VALUES ('c', 's', 300);
INSERT INTO T VALUES ('d', 't', 2147483647);
INSERT INTO T VALUES ('b', 't', 50);
SELECT A, COUNT(*) AS D, SUM(C) AS E FROM T GROUP BY A HAVING COUNT(*) > 1;
INSERT INTO t2(y) VALUES(198),(187),(100);
SELECT y, c FROM t2 LEFT JOIN t1 ON y=a ORDER BY x;
SELECT y, c FROM t1 RIGHT JOIN t2 ON y=a ORDER BY x;
SELECT * FROM t1 NATURAL JOIN t1;
DROP INDEX IF EXISTS t2;
SELECT COUNT(*) FROM t2;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t2_5905 ON t2((y + 1));
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t2_7184 ON t2((x + 1)) WHERE x > 0;
VACUUM;
CREATE TABLE T (
  a TEXT,
  b REAL
);
INSERT INTO T VALUES ('a',100.0), ('b',-200.5), ('c',9e999);
SELECT a,b,
LEAD(b,1) OVER (ORDER BY b DESC) AS c,
NTILE(2) OVER (ORDER BY b DESC) AS d FROM T;
ANALYZE T;
RELEASE sp895;
ALTER TABLE T RENAME TO T_r129;
SELECT STRING_AGG(B) FROM T;
WITH cte AS (SELECT B, COUNT(*) AS cnt FROM T GROUP BY B) SELECT * FROM cte;
INSERT INTO t2 SELECT * FROM t2;
SELECT * FROM T NATURAL JOIN t2;

SELECT COUNT(*) FROM t1;
ALTER TABLE t2 RENAME TO t2_r2071;

REINDEX t2;
SELECT a FROM T EXCEPT SELECT a FROM (SELECT * FROM T) AS sub;
ALTER TABLE t2 RENAME TO t2_r5083;
COMMIT;
```

## Actual output

```sql
0
483
CREATE TABLE "t2"("b","c","_ROWID_",PRIMARY KEY("b","c","_ROWID_"))WITHOUT ROWID;
WARNING: writing to an imposter table will corrupt the "t1bc" index!
von|20|2
Wernher|10|1
Braun|30|3
Braun|30
Wernher|10
von|20
```

## Expectation

```sql
0
483
CREATE TABLE "t2"("b","c","_ROWID_",PRIMARY KEY("b","c","_ROWID_"))WITHOUT ROWID;
von|20|2
Wernher|10|1
Braun|30|3
Braun|30
Wernher|10
von|20
```

## Flag

```

```

