## 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
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
BEGIN TRANSACTION;
ATTACH DATABASE ':memory:' AS aux72;
BEGIN DEFERRED;
CREATE TABLE t1(a);
INSERT INTO t1 VALUES('abc'),('def'),('ghi');
CREATE TABLE t2(a);
INSERT INTO t2 VALUES('DEF'),('abc');
CREATE TABLE t3(a);
INSERT INTO t3 VALUES('def'),('jkl');
SELECT a FROM t1 EXCEPT SELECT a FROM t2 ORDER BY a COLLATE nocase;
SELECT a FROM t2 EXCEPT SELECT a FROM t3 ORDER BY a COLLATE nocase;
SELECT a FROM t2 EXCEPT SELECT a FROM t3 ORDER BY a COLLATE binary;
DELETE FROM t2;
DELETE FROM t3;
INSERT INTO t2 VALUES('ABC'),('def'),('GHI'),('jkl');
INSERT INTO t3 SELECT lower(a) FROM t2; 
SELECT a COLLATE nocase FROM t2 EXCEPT SELECT a FROM t3 ORDER BY 1

CREATE TABLE t1(a);
INSERT INTO t1 VALUES('abc'),('def'),('ghi');
CREATE TABLE t2(a);
INSERT INTO t2 VALUES('DEF'),('abc');
CREATE TABLE t3(a);
INSERT INTO t3 VALUES('def'),('jkl');
SELECT a FROM t1 EXCEPT SELECT a FROM t2 ORDER BY a COLLATE nocase;
SELECT a FROM t2 EXCEPT SELECT a FROM t3 ORDER BY a COLLATE nocase;
SELECT a FROM t2 EXCEPT SELECT a FROM t3 ORDER BY a COLLATE binary;
DELETE FROM t2;
DELETE FROM t3;
INSERT INTO t2 VALUES('ABC'),('def'),('GHI'),('jkl');
INSERT INTO t3 SELECT lower(a) FROM t2; 
SELECT a COLLATE nocase FROM t2 EXCEPT SELECT a FROM t3 ORDER BY 1

CREATE TABLE t1(a);
INSERT INTO t1 VALUES('abc'),('def'),('ghi');
CREATE TABLE t2(a);
INSERT INTO t2 VALUES('DEF'),('abc');
CREATE TABLE t3(a);
INSERT INTO t3 VALUES('def'),('jkl');
SELECT a FROM t1 EXCEPT SELECT a FROM t2 ORDER BY a COLLATE nocase;
SELECT a FROM t2 EXCEPT SELECT a FROM t3 ORDER BY a COLLATE nocase;
SELECT a FROM t2 EXCEPT SELECT a FROM t3 ORDER BY a COLLATE binary;
DELETE FROM t2;
DELETE FROM t3;
INSERT INTO t2 VALUES('ABC'),('def'),('GHI'),('jkl');
INSERT INTO t3 SELECT lower(a) FROM t2; 
SELECT a COLLATE nocase FROM t2 EXCEPT SELECT a FROM t3 ORDER BY 1

CREATE TABLE t1(a);
INSERT INTO t1 VALUES('abc'),('def'),('ghi');
CREATE TABLE t2(a);
INSERT INTO t2 VALUES('DEF'),('abc');
CREATE TABLE t3(a);
INSERT INTO t3 VALUES('def'),('jkl');
SELECT a FROM t1 EXCEPT SELECT a FROM t2 ORDER BY a COLLATE nocase;
SELECT a FROM t2 EXCEPT SELECT a FROM t3 ORDER BY a COLLATE nocase;
SELECT a FROM t2 EXCEPT SELECT a	FROM t3 ORDER BY a COLLATE binary;
DELETE FROM t2;
DELETE FROM t3;
INSERT INTO t2 VALUES('ABC'),('def'),('GHI'),('jkl');
INSERT INTO t3 SELECT lower(a) FROM t2; 
SELECT a COLLATE nocase FROM t2 EXCEPT SELECT a FROM t3 ORDER BY 1


COMMIT;
REINDEX t1;
CREATE UNIQUE  INDEX IF NOT EXISTS idx_t3_1118 ON t3(a COLLATE NOCASE) WHERE a > 0;
DROP INDEX IF EXISTS t2;
SELECT LAST_VALUE(a) OVER (ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t3;
DETACH DATABASE aux72;
ALTER TABLE t1 RENAME COLUMN a TO a_r9525;
ROLLBACK;
ALTER TABLE t3 RENAME COLUMN a TO a_r8773;
PRAGMA defer_foreign_keys = TRUE;
SELECT * FROM t2;
PRAGMA wal_checkpoint('RESTART');
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (NULL) ON CONFLICT(a) DO UPDATE SET a = excluded.a;
```

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

```
-vfs memdb
```

