## 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
SAVEPOINT sp5558;
PRAGMA writable_schema = OFF;
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
SAVEPOINT sp8767;
PRAGMA count_changes = OFF;
CREATE VIRTUAL TABLE t0 USING fts4("x", "y", "z");
DROP TABLE t0;
BEGIN DEFERRED;
SAVEPOINT sp3957;
.exit strftime('' || ('%s'), NULL)
.schema
PRAGMA synchronous IS NOT 'OFF';
ATTACH DATABASE ':memory:' AS aux78;
BEGIN IMMEDIATE TRANSACTION;
PRAGMA recursive_triggers;
.exit CAST(zeroblob('"') AS DATE)
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES (glob('?', 'hello'),'a',abs(x'84a9ab1d')), (json_extract(datetime(atanh(CAST(';' AS INT)), '+1 day'), '$[0]'),'b',-coalesce(NULL, julianday(time(round(2147483647))))), (2,'c',-9e999);
SELECT b,a,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT OR FAIL INTO T VALUES (-1, 3, 0);
PRAGMA quick_check(20);
SELECT MAX(c) FILTER (WHERE NOT NOT (NOT NOT (NOT NOT (NOT NOT (c IS NOT NULL) OVER (PARTITION BY c)))) ORDER BY c RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM T;
ANALYZE T;
END TRANSACTION;
ALTER TABLE T ADD COLUMN extra_4706 NCHAR(55) NOT NULL DEFAULT 0;
SELECT COUNT(*) FROM T;
CREATE TEMP  VIEW IF NOT EXISTS v_T_2390 AS SELECT a FROM T;
ALTER TABLE T DROP COLUMN b;
DELETE FROM T WHERE a IS NULL;
INSERT INTO T VALUES ('x', 1, NULL) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T RENAME TO T_r4177;
ALTER TABLE T RENAME TO T_r7895;
PRAGMA schema_version = 5;
DETACH DATABASE aux78;
ATTACH DATABASE ':memory:' AS aux78;
BEGIN IMMEDIATE TRANSACTION;
PRAGMA recursive_triggers;
.exit CAST(zeroblob('"') AS DATETIME)
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES (glob('?', 'hello'),'a',abs(x'84a9ab1d')), (json_extract(datetime(atanh(CAST(1 AS INT)), '+1 day'), '$[0]'),'b',-7.75), (2,'c',-9e999);
SELECT b,a,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT AND FAIL INTO T VALUES (-1, 3, 0);
PRAGMA quick_check(20);
SELECT MAX(c) FILTER (WHERE c IS NOT NULL) OVER (PARTITION BY c ORDER BY c RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM T;
ANALYZE T;
END TRANSACTION;
ALTER TABLE T ADD COLUMN extra_4706 NCHAR(55) NOT NULL DEFAULT 0;
SELECT COUNT(*) FROM T;
CREATE TEMP  VIEW IF NOT EXISTS v_T_2390 AS SELECT a FROM T;
ALTER TABLE T DROP COLUMN b;
DELETE FROM T WHERE a IS NULL;
INSERT INTO T VALUES ('x', 1, NULL) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T RENAME TO T_r4177;
ALTER TABLE T RENAME TO T_r7895;
PRAGMA schema_version = 5;
DETACH DATABASE aux78;
ATTACH DATABASE ':memory:' AS aux78;
BEGIN IMMEDIATE TRANSACTION;
PRAGMA recursive_triggers;
.exit CAST(zeroblob('"') AS DATETIME)
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES (glob('?', 'hello'),'a',abs(x'84a9ab1d')), (json_extract(datetime(atanh(CAST(1 AS INT)), '+1 day'), '$[0]'),'b',-7.75), (2,'c',-9e999);
SELECT b,a,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT AND FAIL INTO T VALUES (-1, 3, 0);
PRAGMA quick_check(20);
SELECT MAX(c) FILTER (WHERE c IS NOT NULL) OVER (PARTITION BY c ORDER BY c RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM T;
ANALYZE T;
END TRANSACTION;
ALTER TABLE T ADD COLUMN extra_4706 NCHAR(55) NOT NULL DEFAULT 0;
SELECT COUNT(*) FROM T;
CREATE TEMP  VIEW IF NOT EXISTS v_T_2390 AS SELECT a FROM T;
ALTER TABLE T DROP COLUMN b;
DELETE FROM T WHERE a IS NULL;
INSERT INTO T VALUES ('x', 1, NULL) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T RENAME TO T_r4177;
ALTER TABLE T RENAME TO T_r7895;
PRAGMA schema_version = 5;
DETACH DATABASE aux78;
ATTACH DATABASE ':memory:' AS aux78;
BEGIN IMMEDIATE TRANSACTION;
PRAGMA recursive_triggers;
.exit CAST(zeroblob('"') AS DATETIME)
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES (glob('?', 'hello'),'a',abs(x'84a9ab1d')), (json_extract(datetime(atanh(CAST(1 AS INT)), '+1 day'), '$[0]'),'b',-7.75), (2,'c',-9e999);
SELECT b,a,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT AND FAIL INTO T VALUES (-1, 3, 0);
PRAGMA quick_check(20);
SELECT MAX(c) FILTER (WHERE c IS NOT NULL) OVER (PARTITION BY c ORDER BY c RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM T;
ANALYZE T;
END TRANSACTION;
ALTER TABLE T ADD COLUMN extra_4706 NCHAR(55) NOT NULL DEFAULT 0;
SELECT COUNT(*) FROM T;
CREATE TEMP  VIEW IF NOT EXISTS v_T_2390 AS SELECT a FROM T;
ALTER TABLE T DROP COLUMN b;
DELETE FROM T WHERE a IS NULL;
INSERT INTO T VALUES ('x', 1, NULL) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T RENAME TO T_r4177;
ALTER TABLE T RENAME TO T_r7895;
PRAGMA schema_version = 5;
DETACH DATABASE aux78;
ATTACH DATABASE ':memory:' AS aux78;
BEGIN IMMEDIATE TRANSACTION;
PRAGMA recursive_triggers;
.exit CAST(zeroblob('"') AS DATETIME)
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES (glob('?', 'hello'),'a',abs(x'84a9ab1d')), (json_extract(datetime(atanh(CAST(1 AS INT)), '+1 day'), '$[0]'),'b',-7.75), (2,'c',-9e999);
SELECT b,a,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT AND FAIL INTO T VALUES (-1, 3, 0);
PRAGMA quick_check(20);
SELECT MAX(c) FILTER (WHERE c IS NOT NULL) OVER (PARTITION BY c ORDER BY c RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM T;
ANALYZE T;
END TRANSACTION;
ALTER TABLE T ADD COLUMN extra_4706 NCHAR(55) NOT NULL DEFAULT 0;
SELECT COUNT(*) FROM T;
CREATE TEMP  VIEW IF NOT EXISTS v_T_2390 AS SELECT a FROM T;
ALTER TABLE T DROP COLUMN b;
DELETE FROM T WHERE a IS NULL;
INSERT INTO T VALUES ('x', 1, NULL) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T RENAME TO T_r4177;
ALTER TABLE T RENAME TO T_r7895;
PRAGMA schema_version = 5;
DETACH DATABASE aux78;
ATTACH DATABASE ':memory:' AS aux78;
BEGIN IMMEDIATE TRANSACTION;
PRAGMA recursive_triggers;
.exit CAST(zeroblob('"') AS DATETIME)
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES (glob('?', 'hello'),'a',abs(x'84a9ab1d')), (json_extract(datetime(atanh(CAST(1 AS INT)), '+1 day'), '$[0]'),'b',-7.75), (2,'c',-9e999);
SELECT b,a,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT AND FAIL INTO T VALUES (-1, 3, 0);
PRAGMA quick_check(20);
SELECT MAX(c) FILTER (WHERE c IS NOT NULL) OVER (PARTITION BY c ORDER BY c RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM T;
ANALYZE T;
END TRANSACTION;
ALTER TABLE T ADD COLUMN extra_4706 NCHAR(55) NOT NULL DEFAULT 0;
SELECT COUNT(*) FROM T;
CREATE TEMP  VIEW IF NOT EXISTS v_T_2390 AS SELECT a FROM T;
ALTER TABLE T DROP COLUMN b;
DELETE FROM T WHERE a IS NULL;
INSERT INTO T VALUES ('x', 1, NULL) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T RENAME TO T_r4177;
ALTER TABLE T RENAME TO T_r7895;
PRAGMA schema_version = 5;
DETACH DATABASE aux78;
ATTACH DATABASE ':memory:' AS aux78;
BEGIN IMMEDIATE TRANSACTION;
PRAGMA recursive_triggers;
.exit CAST(zeroblob('"') AS DATETIME)
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES (glob('?', 'hello'),'a',abs(x'84a9ab1d')), (json_extract(datetime(atanh(CAST(1 AS INT)), '+1 day'), '$[0]'),'b',-7.75), (2,'c',-9e999);
SELECT b,a,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT AND FAIL INTO T VALUES (-1, 3, 0);
PRAGMA quick_check(20);
SELECT MAX(c) FILTER (WHERE c IS NOT NULL) OVER (PARTITION BY c ORDER BY c RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) FROM T;
ANALYZE T;
END TRANSACTION;
ALTER TABLE T ADD COLUMN extra_4706 NCHAR(55) NOT NULL DEFAULT 0;
SELECT COUNT(*) FROM T;
CREATE TEMP  VIEW IF NOT EXISTS v_T_2390 AS SELECT a FROM T;
ALTER TABLE T DROP COLUMN b;
DELETE FROM T WHERE a IS NULL;
INSERT INTO T VALUES ('x', 1, NULL) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T RENAME TO T_r4177;
ALTER TABLE T RENAME TO T_r7895;
PRAGMA schema_version = 5;
DETACH DATABASE aux78;
SELECT COUNT(*) FILTER (WHERE a IS NOT NULL), SUM(rowid) FILTER (WHERE a > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(a) FILTER (WHERE a > 0 AND a < 100), COUNT(*) FILTER (WHERE typeof(a) = "text") FROM T;
SELECT NTH_VALUE(b, 2) OVER (PARTITION BY b ORDER BY b RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING EXCLUDE NO OTHERS) FROM T;
SELECT AVG(b) FROM T;
DROP VIEW IF EXISTS T;
VACUUM main;
INSERT INTO T DEFAULT VALUES;
ALTER TABLE T DROP COLUMN b;
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;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_T_4427 ON T(lower(b));
ALTER TABLE T DROP COLUMN a;
CREATE  INDEX IF NOT EXISTS idx_T_4716 ON T(c COLLATE NOCASE);
VACUUM main;
INSERT INTO T VALUES (NULL, NULL, NULL);
UPDATE T SET a = CURRENT_TIMESTAMP WHERE a IS NOT NULL RETURNING *;
SELECT * FROM T FULL JOIN T;
UPDATE T SET a = '' WHERE a BETWEEN 0 AND 100;
INSERT OR ROLLBACK INTO T VALUES (0, 'x', 0);
ALTER TABLE T ADD COLUMN extra_3521 CHARACTER(20) DEFAULT (random());
CREATE TABLE T (
  a INTEGER,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES (1,'a',1.25), (2,'b',-3.5), (3,'c',0.0);
CREATE TABLE T (
  a INTEGER,
  b REAL
);
INSERT INTO T VALUES (1,1.5), (2,-7.25), (3,0.0);
SELECT a,b FROM T WHERE a >= 2 ORDER BY b;
SELECT * FROM T WHERE c < 2.0 ORDER BY c;
SELECT * FROM T WHERE a = (SELECT COUNT(*) FROM T);
INSERT INTO T VALUES (NULL, 'x', NULL) ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T RENAME COLUMN a TO a_r6404;
INSERT INTO T DEFAULT VALUES;
ROLLBACK TRANSACTION TO SAVEPOINT sp3957;
RELEASE SAVEPOINT sp3957;
END;
DELETE FROM T WHERE b > (SELECT AVG(b) FROM T) RETURNING *;
ALTER TABLE T DROP COLUMN c;
ALTER TABLE T RENAME COLUMN a TO a_r6310;
SELECT * FROM (SELECT a, COUNT(*) FROM T GROUP BY a) AS sub;
SELECT * FROM T;
PRAGMA encoding = 'UTF-16be';
SELECT * FROM T NATURAL JOIN T;
DROP TABLE IF EXISTS T;
SELECT * FROM T WHERE b <= ANY (SELECT b FROM T);
ALTER TABLE T RENAME COLUMN c TO c_r1983;
SELECT AVG(c) FROM T;
INSERT INTO T SELECT * FROM T;
SELECT GROUP_CONCAT(c, '|') FROM T;
ALTER TABLE T ADD COLUMN extra_8345 BOOLEAN DEFAULT (random());
PRAGMA empty_result_callbacks = YES;
SELECT * FROM T;
ANALYZE;
DROP VIEW IF EXISTS T;
DROP TABLE IF EXISTS T;
CREATE  VIEW IF NOT EXISTS v_T_5407 AS SELECT a FROM T;

SELECT COUNT(*) FROM T;
REINDEX T;
SELECT * FROM T;
REINDEX T;
ROLLBACK TO sp8767;
RELEASE sp8767;
SELECT * FROM T WHERE EXISTS (SELECT 1 FROM T t2 WHERE t2.b = T.b);
CREATE TEMP  VIEW IF NOT EXISTS v_t1_7429 AS SELECT b FROM t1;
SELECT * FROM T WHERE b = (SELECT b FROM T t2 WHERE t2.b = T.b LIMIT 1);
REINDEX T;
ROLLBACK TO sp5558;
RELEASE sp5558;
DROP INDEX IF EXISTS t1;
INSERT INTO t1 DEFAULT VALUES;
REINDEX;
```

## 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!
Braun|30|3
Wernher|10|-1
von|20|2
Braun|30
Wernher|10
von|20
```

## Expectation

```sql
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

```
-deserialize
```

