## 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
.stats
CREATE TABLE main.t1(a, b TEXT);
CREATE UNIQUE INDEX IF NOT EXISTS x1 ON t1(b==log((-(-(-ifnull('{', 'fallback'))) * 1), 0));
CREATE INDEX IF NOT EXISTS x2 ON t1(a || 0) WHERE b;
INSERT INTO t1(a,b) VALUES('a',1),('a',0);
SELECT a, b, '|' FROM t1;

DROP INDEX IF EXISTS t1;
WITH m AS MATERIALIZED (SELECT a FROM t1) SELECT * FROM m;
UPDATE t1 SET a = CURRENT_TIMESTAMP WHERE a BETWEEN 0 AND 100 RETURNING *;
SELECT LAG(a, 0) OVER (PARTITION BY a ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t1;
SELECT MAX(a) FROM t1;
SELECT * FROM t1;
VACUUM main;
SELECT * FROM t1 WHERE b IN (SELECT b FROM t1 LIMIT 0);
ALTER TABLE t1 RENAME TO t1_r2082;
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
VACUUM main;
ALTER TABLE t1 DROP COLUMN a;
ALTER TABLE t1 ADD COLUMN extra_4108 BIGINT;
DELETE FROM t1 WHERE rowid = 7;
.stats
CREATE TABLE main.t1(a, b TEXT);
CREATE UNIQUE INDEX IF NOT EXISTS x1 ON t1(b==log((-(-(-ifnull('{', 'fallback'))) * 1), 0));
CREATE INDEX IF NOT EXISTS x2 ON t1(a || 0) WHERE b;
INSERT INTO t1(a,b) VALUES('a',1),('a',0);
SELECT a, b, '|' FROM t1;

DROP INDEX IF EXISTS t1;
WITH m AS MATERIALIZED (SELECT a FROM t1) SELECT * FROM m;
UPDATE t1 SET a = CURRENT_TIMESTAMP WHERE a BETWEEN 0 AND 100 RETURNING *;
SELECT LAG(a, 0) OVER (PARTITION BY a ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t1;
SELECT MAX(a) FROM t1;
SELECT * FROM t1;
VACUUM main;
SELECT * FROM t1 WHERE b IN (SELECT b FROM t1 LIMIT 0);
ALTER TABLE t1 RENAME TO t1_r2082;
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
VACUUM main;
ALTER TABLE t1 DROP COLUMN a;
ALTER TABLE t1 ADD COLUMN extra_4108 BIGINT;
DELETE FROM t1 WHERE rowid = 7;
.stats
CREATE TABLE main.t1(a, b TEXT);
CREATE UNIQUE INDEX IF NOT EXISTS x1 ON t1(b==log((-(-(-ifnull('{', 'fallback'))) * 1), 0));
CREATE INDEX IF NOT EXISTS x2 ON t1(a || 0) WHERE b;
INSERT INTO t1(a,b) VALUES('a',1),('a',0);
SELECT a, b, '|' FROM t1;

DROP INDEX IF EXISTS t1;
WITH m AS MATERIALIZED (SELECT a FROM t1) SELECT * FROM m;
UPDATE t1 SET a = CURRENT_TIMESTAMP WHERE a BETWEEN 0 AND 100 RETURNING *;
SELECT LAG(a, 0) OVER (PARTITION BY a ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t1;
SELECT MAX(a) FROM t1;
SELECT * FROM t1;
VACUUM main;
SELECT * FROM t1 WHERE b IN (SELECT b FROM t1 LIMIT 0);
ALTER TABLE t1 RENAME TO t1_r2082;
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
VACUUM main;
ALTER TABLE t1 DROP COLUMN a;
ALTER TABLE t1 ADD COLUMN extra_4108 BIGINT;
DELETE FROM t1 WHERE rowid = 7;
.stats
CREATE TABLE main.t1(a, b TEXT);
CREATE UNIQUE INDEX IF NOT EXISTS x1 ON t1(b==log((-(-(-ifnull('{', 'fallback'))) * 1), 0));
CREATE INDEX IF NOT EXISTS x2 ON t1(a || 0) WHERE b;
INSERT INTO t1(a,b) VALUES('a',1),('a',0);
SELECT a, b, '|' FROM t1;

DROP INDEX IF EXISTS t1;
WITH m AS MATERIALIZED (SELECT a FROM t1) SELECT * FROM m;
UPDATE t1 SET a = CURRENT_TIMESTAMP WHERE a BETWEEN 0 AND 100 RETURNING *;
SELECT LAG(a, 0) OVER (PARTITION BY a ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t1;
SELECT MAX(a) FROM t1;
SELECT * FROM t1;
VACUUM main;
SELECT * FROM t1 WHERE b IN (SELECT b FROM t1 LIMIT 0);
ALTER TABLE t1 RENAME TO t1_r2082;
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
VACUUM main;
ALTER TABLE t1 DROP COLUMN a;
ALTER TABLE t1 ADD COLUMN extra_4108 BIGINT;
DELETE FROM t1 WHERE rowid = 7;
.stats
CREATE TABLE main.t1(a, b TEXT);
CREATE UNIQUE INDEX IF NOT EXISTS x1 ON t1(b==log((-(-(-ifnull('{', 'fallback'))) * 1), 0));
CREATE INDEX IF NOT EXISTS x2 ON t1(a || 0) WHERE b;
INSERT INTO t1(a,b) VALUES('a',1),('a',0);
SELECT a, b, '|' FROM t1;

DROP INDEX IF EXISTS t1;
WITH m AS MATERIALIZED (SELECT a FROM t1) SELECT * FROM m;
UPDATE t1 SET a = CURRENT_TIMESTAMP WHERE a BETWEEN 0 AND 100 RETURNING *;
SELECT LAG(a, 0) OVER (PARTITION BY a ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t1;
SELECT MAX(a) FROM t1;
SELECT * FROM t1;
VACUUM main;
SELECT * FROM t1 WHERE b IN (SELECT b FROM t1 LIMIT 0);
ALTER TABLE t1 RENAME TO t1_r2082;
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
VACUUM main;
ALTER TABLE t1 DROP COLUMN a;
ALTER TABLE t1 ADD COLUMN extra_4108 BIGINT;
DELETE FROM t1 WHERE rowid = 7;
.stats
CREATE TABLE main.t1(a, b TEXT);
CREATE UNIQUE INDEX IF NOT EXISTS x1 ON t1(b==log((-(-(-ifnull('{', 'fallback'))) * 1), 0));
CREATE INDEX IF NOT EXISTS x2 ON t1(a || 0) WHERE b;
INSERT INTO t1(a,b) VALUES('a',1),('a',0);
SELECT a, b, '|' FROM t1;

DROP INDEX IF EXISTS t1;
WITH m AS MATERIALIZED (SELECT a FROM t1) SELECT * FROM m;
UPDATE t1 SET a = CURRENT_TIMESTAMP WHERE a BETWEEN 0 AND 100 RETURNING *;
SELECT LAG(a, 0) OVER (PARTITION BY a ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t1;
SELECT MAX(a) FROM t1;
SELECT * FROM t1;
VACUUM main;
SELECT * FROM t1 WHERE b IN (SELECT b FROM t1 LIMIT 0);
ALTER TABLE t1 RENAME TO t1_r2082;
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
VACUUM main;
ALTER TABLE t1 DROP COLUMN a;
ALTER TABLE t1 ADD COLUMN extra_4108 BIGINT;
DELETE FROM t1 WHERE rowid = 7;
.stats
CREATE TABLE main.t1(a, b TEXT);
CREATE UNIQUE INDEX IF NOT EXISTS x1 ON t1(b==log((-(-(-ifnull('{', 'fallback'))) * 1), 0));
CREATE INDEX IF NOT EXISTS x2 ON t1(a || 0) WHERE b;
INSERT INTO t1(a,b) VALUES('a',1),('a',0);
SELECT a, b, '|' FROM t1;

DROP INDEX IF EXISTS t1;
WITH m AS MATERIALIZED (SELECT a FROM t1) SELECT * FROM m;
UPDATE t1 SET a = CURRENT_TIMESTAMP WHERE a BETWEEN 0 AND 100 RETURNING *;
SELECT LAG(a, 0) OVER (PARTITION BY a ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t1;
SELECT MAX(a) FROM t1;
SELECT * FROM t1;
VACUUM main;
SELECT * FROM t1 WHERE b IN (SELECT b FROM t1 LIMIT 0);
ALTER TABLE t1 RENAME TO t1_r2082;
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
VACUUM main;
ALTER TABLE t1 DROP COLUMN a;
ALTER TABLE t1 ADD COLUMN extra_4108 BIGINT;
DELETE FROM t1 WHERE rowid = 7;
.stats
CREATE TABLE main.t1(a, b TEXT);
CREATE UNIQUE INDEX IF NOT EXISTS x1 ON t1(b==log((-(-(-ifnull('{', 'fallback'))) * 1), 0));
CREATE INDEX IF NOT EXISTS x2 ON t1(a || 0) WHERE b;
INSERT INTO t1(a,b) VALUES('a',1),('a',0);
SELECT a, b, '|' FROM t1;

DROP INDEX IF EXISTS t1;
WITH m AS MATERIALIZED (SELECT a FROM t1) SELECT * FROM m;
UPDATE t1 SET a = CURRENT_TIMESTAMP WHERE a BETWEEN 0 AND 100 RETURNING *;
SELECT LAG(a, 0) OVER (PARTITION BY a ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t1;
SELECT MAX(a) FROM t1;
SELECT * FROM t1;
VACUUM main;
SELECT * FROM t1 WHERE b IN (SELECT b FROM t1 LIMIT 0);
ALTER TABLE t1 RENAME TO t1_r2082;
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
VACUUM main;
ALTER TABLE t1 DROP COLUMN a;
ALTER TABLE t1 ADD COLUMN extra_4108 BIGINT;
DELETE FROM t1 WHERE rowid = 7;
.stats
CREATE TABLE main.t1(a, b TEXT);
CREATE UNIQUE INDEX IF NOT EXISTS x1 ON t1(b==log((-(-(-ifnull('{', 'fallback'))) * 1), 0));
CREATE INDEX IF NOT EXISTS x2 ON t1(a || 0) WHERE b;
INSERT INTO t1(a,b) VALUES('a',1),('a',0);
SELECT a, b, '|' FROM t1;

DROP INDEX IF EXISTS t1;
WITH m AS MATERIALIZED (SELECT a FROM t1) SELECT * FROM m;
UPDATE t1 SET a = CURRENT_TIMESTAMP WHERE a BETWEEN 0 AND 100 RETURNING *;
SELECT LAG(a, 0) OVER (PARTITION BY a ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t1;
SELECT MAX(a) FROM t1;
SELECT * FROM t1;
VACUUM main;
SELECT * FROM t1 WHERE b IN (SELECT b FROM t1 LIMIT 0);
ALTER TABLE t1 RENAME TO t1_r2082;
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
VACUUM main;
ALTER TABLE t1 DROP COLUMN a;
ALTER TABLE t1 ADD COLUMN extra_4108 BIGINT;
DELETE FROM t1 WHERE rowid = 7;

INSERT INTO t1 SELECT * FROM t1;
```

## Actual output

```sql
Memory Used:                         0 (max 64) bytes
Number of Outstanding Allocations:   0 (max 2)
Number of Pcache Overflow Bytes:     0 (max 0) bytes
Largest Allocation:                  40 bytes
Largest Pcache Allocation:           0 bytes
Bytes received by read():            10409
Bytes sent to write():               0
Read() system calls:                 13
Write() system calls:                0
Bytes read from storage:             0
Bytes written to storage:            0
Cancelled write bytes:               0
a|1||
a|0||
a
a
a
a
a
a|1
a|0
CREATE TABLE "t2"("b","c","_ROWID_",PRIMARY KEY("b","c","_ROWID_"))WITHOUT ROWID;
WARNING: writing to an imposter table will corrupt the "t1bc" index!
Braun|30|3
Wernher|10|1
von|20|2
Braun|30
Wernher|10
von|20
```

## Expectation

```sql
Memory Used:                         0 (max 56) bytes
Number of Outstanding Allocations:   0 (max 2)
Number of Pcache Overflow Bytes:     0 (max 0) bytes
Largest Allocation:                  40 bytes
Largest Pcache Allocation:           0 bytes
Bytes received by read():            11185
Bytes sent to write():               0
Read() system calls:                 14
Write() system calls:                0
Bytes read from storage:             0
Bytes written to storage:            0
Cancelled write bytes:               0
a|1||
a|0||
a
a
a
a
a
a|1
a|0
CREATE TABLE "t2"("b","c","_ROWID_",PRIMARY KEY("b","c","_ROWID_"))WITHOUT ROWID;
Braun|30|3
Wernher|10|1
von|20|2
Braun|30
Wernher|10
von|20
```

## Flag

```

```

