## 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 aux77;
-- max(1, 2, 3, 4, 5)

.headers on
PRAGMA automatic_index = NO;
PRAGMA automatic_index = YES;
CREATE TABLE T (
  a TEXT,
  b REAL
);
INSERT INTO T VALUES ('a',load_extension(NULL)), ('b',-jsonb_extract(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;
PRAGMA checkpoint_fullsync = FALSE;
BEGIN EXCLUSIVE TRANSACTION;
ATTACH DATABASE ':memory:' AS aux85;
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
UPDATE t1 SET d = 'x' WHERE d IS NOT NULL;
CREATE TRIGGER IF NOT EXISTS trg_t1_5828 AFTER UPDATE OF d ON t1 BEGIN SELECT RAISE(FAIL, 'no'); END;
SELECT TOTAL(a) FROM t1;
PRAGMA mmap_size = 50000000;
DETACH DATABASE aux85;
SELECT * FROM t1 WHERE c > (SELECT AVG(c) FROM t1);
COMMIT TRANSACTION;
ALTER TABLE t1 RENAME TO t1_r4016;
INSERT INTO t1 DEFAULT VALUES;
PRAGMA checkpoint_fullsync = FALSE;
BEGIN EXCLUSIVE TRANSACTION;
ATTACH DATABASE ':memory:' AS aux85;
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
UPDATE t1 SET d = 'x' WHERE d IS NOT NULL;
CREATE TRIGGER IF NOT EXISTS trg_t1_5828 AFTER UPDATE OF d /* .dump main */ ON t1 BEGIN SELECT RAISE(FAIL, 'no'); END;
SELECT TOTAL(a) FROM t1;
PRAGMA mmap_size = 50000000;
DETACH DATABASE aux85;
SELECT * FROM t1 WHERE c > (SELECT AVG(c) FROM t1);
COMMIT TRANSACTION;
ALTER TABLE t1 RENAME TO t1_r4016;
INSERT INTO t1 DEFAULT VALUES;
PRAGMA checkpoint_fullsync = FALSE;
BEGIN EXCLUSIVE TRANSACTION;
ATTACH DATABASE ':memory:' AS aux85;
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
UPDATE t1 SET d = 'x' WHERE d IS NOT NULL;
CREATE TRIGGER IF NOT EXISTS trg_t1_5828 AFTER UPDATE OF d ON t1 BEGIN SELECT RAISE(FAIL, 'no'); END;
SELECT TOTAL(a) FROM t1;
PRAGMA mmap_size = 50000000;
DETACH DATABASE aux85;
SELECT * FROM t1 WHERE c > (SELECT AVG(c) FROM t1);
COMMIT TRANSACTION;
ALTER TABLE t1 RENAME TO t1_r4016;
INSERT INTO t1 DEFAULT VALUES;
PRAGMA checkpoint_fullsync = FALSE;
BEGIN EXCLUSIVE TRANSACTION;
ATTACH DATABASE ':memory:' AS aux85;
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
UPDATE t1 SET d = 'x' WHERE d IS NOT NULL;
CREATE TRIGGER IF NOT EXISTS trg_t1_5828 AFTER UPDATE OF d ON t1 BEGIN /**/ SELECT RAISE(FAIL, 'no'); END;
SELECT TOTAL(a) FROM t1;
PRAGMA mmap_size = 50000000;
DETACH DATABASE aux85;
SELECT * FROM t1 WHERE c > (SELECT AVG(c) FROM t1);
COMMIT TRANSACTION;
ALTER TABLE t1 RENAME TO t1_r4016;
INSERT INTO t1 DEFAULT VALUES;

ALTER TABLE t1 RENAME TO t1_r1422;

SELECT COUNT(*) FROM T;

SELECT COUNT(*) FROM t1;
INSERT OR REPLACE INTO t1 VALUES (0, '', '', NULL);
SELECT * FROM T;
SELECT AVG(a) OVER (PARTITION BY a ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM T;
SELECT * FROM T AS a FULL JOIN T AS b ON a.rowid = b.rowid;
SELECT MAX(a) FROM T;
CREATE TRIGGER IF NOT EXISTS trg_T_9386 AFTER UPDATE OF b ON T BEGIN INSERT INTO T(b) VALUES (NULL); END;
INSERT INTO t1 VALUES (NULL, NULL, 1, 'x') ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
INSERT INTO T DEFAULT VALUES;
SELECT COUNT(*) FILTER (WHERE b IS NOT NULL), SUM(rowid) FILTER (WHERE b > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(b) FILTER (WHERE b > 0 AND b < 100), COUNT(*) FILTER (WHERE typeof(b) = "text") FROM T;
DETACH DATABASE aux77;
DELETE FROM T WHERE rowid = 8 RETURNING *;
CREATE  INDEX IF NOT EXISTS idx_t1_6079 ON t1(a COLLATE NOCASE) WHERE a IS NOT NULL;
REINDEX t1;
ALTER TABLE T ADD COLUMN extra_3272 REAL;
ANALYZE;
```

## Actual output

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

## Expectation

```sql

```

## Flag

```

```

