## 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
PRAGMA legacy_alter_table = YES;
SAVEPOINT sp3593;
SAVEPOINT sp1295;
-- PRAGMA query_only = TRUE;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('' || ('a'),'b',x'7867e8af9497c5a82a529f0a962940'), ('a','c',NULL), ('b','d',-CAST(CAST(3.141592653589793 AS DECIMAL(10,5)) AS CHARINT));
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
SELECT
a,b,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT INTO T DEFAULT VALUES;
ROLLBACK TO sp1295;
RELEASE sp1295;
INSERT INTO T VALUES (1, 1, 'x') ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T DROP COLUMN a;
DROP TABLE IF EXISTS T;
SELECT * FROM (SELECT * FROM t1) AS t1 JOIN (SELECT * FROM t1) AS t2 ON t1.d = t2.d;
SELECT GROUP_CONCAT(c) FROM t1;
UPDATE T SET c = 'x' WHERE c IS NOT NULL;
WITH cte AS (SELECT NULL AS x) SELECT COALESCE(x, 0) FROM cte;
ALTER TABLE t1 DROP COLUMN a;
SAVEPOINT sp1295;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('a','b',x'7867e8af9497c5a82a529f0a962940'), ('a','c',NULL), ('b','d',-CAST(8.25 AS CHARINT));
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
SELECT a,b,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT INTO T DEFAULT VALUES;
ROLLBACK TO sp1295;
RELEASE sp1295;
INSERT INTO T VALUES (1, 1, 'x') ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T DROP COLUMN a;
DROP TABLE IF EXISTS T;
SELECT * FROM (SELECT * FROM t1) AS t1 JOIN (SELECT * FROM t1) AS t2 ON t1.d = t2.d;
SELECT GROUP_CONCAT(c) FROM t1;
UPDATE T SET c = 'x' WHERE c IS NOT NULL;
WITH cte AS (SELECT NULL AS x) SELECT COALESCE(x, 0) FROM cte;
ALTER TABLE t1 DROP COLUMN a;
SAVEPOINT sp1295;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('a','b',x'7867e8af9497c5a82a529f0a962940'), ('a','c',NULL), ('b','d',-CAST(8.25 AS CHARINT));
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
SELECT a,b,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT INTO T DEFAULT VALUES;
ROLLBACK TO sp1295;
RELEASE sp1295;
INSERT INTO T VALUES (1, 1, 'x') ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T DROP COLUMN a;
DROP TABLE IF EXISTS T;
SELECT * FROM (SELECT * FROM t1) AS t1 JOIN (SELECT * FROM t1) AS t2 ON t1.d = t2.d;
SELECT GROUP_CONCAT(c) FROM t1;
UPDATE T SET c = 'x' WHERE c IS NOT NULL;
WITH cte AS (SELECT NULL AS x) SELECT COALESCE(x, 0) FROM cte;
ALTER TABLE t1 DROP COLUMN a;
SAVEPOINT sp1295;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('a','b',x'7867e8af9497c5a82a529f0a962940'), ('a','c',NULL), ('b','d',-CAST(8.25 AS CHARINT));
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
SELECT a,b,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT INTO T DEFAULT VALUES;
ROLLBACK TO sp1295;
RELEASE sp1295;
INSERT INTO T VALUES (1, 1, 'x') ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T DROP COLUMN a;
DROP TABLE IF EXISTS T;
SELECT * FROM (SELECT * FROM t1) AS t1 JOIN (SELECT * FROM t1) AS t2 ON t1.d = t2.d;
SELECT GROUP_CONCAT(c) FROM t1;
UPDATE T SET c = 'x' WHERE c IS NOT NULL;
WITH cte AS (SELECT NULL AS x) SELECT COALESCE(x, 0) FROM cte;
ALTER TABLE t1 DROP COLUMN a;
SAVEPOINT sp1295;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('a','b',x'7867e8af9497c5a82a529f0a962940'), ('a','c',NULL), ('b','d',-CAST(8.25 AS CHARINT));
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
SELECT a,b,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT INTO T DEFAULT VALUES;
ROLLBACK TO sp1295;
RELEASE sp1295;
INSERT INTO T VALUES (1, 1, 'x') ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T DROP COLUMN a;
DROP TABLE IF EXISTS T;
SELECT * FROM (SELECT * FROM t1) AS t1 JOIN (SELECT * FROM t1) AS t2 ON t1.d = t2.d;
SELECT GROUP_CONCAT(c) FROM t1;
UPDATE T SET c = 'x' WHERE c IS NOT NULL;
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;
WITH cte AS (SELECT NULL AS x) SELECT COALESCE(x, 0) FROM cte;
ALTER TABLE t1 DROP COLUMN a;
SAVEPOINT sp1295;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('a','b',x'7867e8af9497c5a82a529f0a962940'), ('a','c',NULL), ('b','d',-CAST(8.25 AS CHARINT));
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
SELECT a,b,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT INTO T DEFAULT VALUES;
ROLLBACK TO sp1295;
RELEASE sp1295;
INSERT INTO T VALUES (1, 1, 'x') ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T DROP COLUMN a;
DROP TABLE IF EXISTS T;
SELECT * FROM (SELECT * FROM t1) AS t1 JOIN (SELECT * FROM t1) AS t2 ON t1.d = t2.d;
SELECT GROUP_CONCAT(c) FROM t1;
UPDATE T SET c = 'x' WHERE c IS NOT NULL;
WITH cte AS (SELECT NULL AS x) SELECT COALESCE(x, 0) FROM cte;
ALTER TABLE t1 DROP COLUMN a;
SAVEPOINT sp1295;
CREATE TABLE T (
  a TEXT,
  b TEXT,
  c REAL
);
INSERT INTO T VALUES ('a','b',x'7867e8af9497c5a82a529f0a962940'), ('a','c',NULL), ('b','d',-CAST(8.25 AS CHARINT));
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
SELECT a,b,c,
RANK() OVER (PARTITION BY a ORDER BY c DESC) AS d FROM T;
INSERT INTO T DEFAULT VALUES;
ROLLBACK TO sp1295;
RELEASE sp1295;
INSERT INTO T VALUES (1, 1, 'x') ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
ALTER TABLE T DROP COLUMN a;
DROP TABLE IF EXISTS T;
SELECT * FROM (SELECT * FROM t1) AS t1 JOIN (SELECT * FROM t1) AS t2 ON t1.d = t2.d;
SELECT GROUP_CONCAT(c) FROM t1;
UPDATE T SET c = 'x' WHERE c IS NOT NULL;
WITH cte AS (SELECT NULL AS x) SELECT COALESCE(x, 0) FROM cte;
ALTER TABLE t1 DROP COLUMN a;
SELECT COUNT(*) FILTER (WHERE d IS NOT NULL), SUM(rowid) FILTER (WHERE d > 0), COUNT(*) FILTER (WHERE 1=0), COUNT(*) FILTER (WHERE 1=1), COUNT(*) FILTER (WHERE NULL), AVG(d) FILTER (WHERE d > 0 OR d < 100), COUNT(*) FILTER (WHERE typeof(d) = "text") FROM t1;
INSERT INTO t1 VALUES ('x', NULL, 'x', 'x') ON CONFLICT(a) DO UPDATE SET a = excluded.a, b = excluded.b, c = excluded.c;
SELECT STRING_AGG(b) FROM T;
SELECT * FROM t1 AS a LEFT JOIN t1 AS b ON a.rowid = b.rowid;
SELECT MIN(c) FILTER (WHERE c IS NOT NULL) OVER (PARTITION BY c ORDER BY c ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) FROM T;
CREATE TABLE T1 (
  a INTEGER,
  b REAL
);
CREATE TABLE T2 (
  a INTEGER,
  b REAL
);
INSERT INTO T1 VALUES (1,1.0);
INSERT INTO T2 VALUES (1,-1.0),(2,9e999);
INSERT OR REPLACE INTO T1
SELECT * FROM T2;
SELECT * FROM T1;
SELECT * FROM T2 WHERE a IN (SELECT a FROM T2);
SELECT COUNT(*) FROM T1;
VACUUM main;
SELECT STRING_AGG(c) FROM T;
CREATE TABLE T (
  A VARCHAR(20),
  B VARCHAR(10),
  PRIMARY KEY (A, B)
);
INSERT INTO T VALUES ('a', 'p');
INSERT INTO T VALUES ('a', 'q');
INSERT INTO T VALUES ('b', 'q');
INSERT INTO T VALUES ('c', 'r');
INSERT INTO T VALUES ('b', 'r');
INSERT INTO T VALUES ('b', 't');
SELECT B, COUNT(DISTINCT A) AS D FROM T GROUP BY B ORDER BY D DESC, B ASC;
DROP TRIGGER IF EXISTS T2;
CREATE  INDEX IF NOT EXISTS idx_T_3562 ON T(lower(B)) WHERE B > 0;
ROLLBACK TO sp3593;
RELEASE sp3593;
VACUUM;
```

## 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

```

```

